atoz Posted September 30, 2003 Posted September 30, 2003 i have done some connections to database as well as the filling of dataset.. ... ..only to realize that to use the records in that dataset, the only possible way is to establish connections and fill it in the same method as in which i want its values to be displayed. The connection has to be done once again if i were to access the intTotalRow count in another method. intTotalRow = datasetTest.Tables(strTblName).Rows.Count the reason i wanna separated intTotalRow count to another method instead of putting it with my dataset Connection is that the codes can be reused. To save lines.. i created my own method with parameters.. Pls Help... Thank you Quote
atoz Posted September 30, 2003 Author Posted September 30, 2003 Codes can be reused as in i have a no. of datasets in my page. Quote
Moderators Robby Posted September 30, 2003 Moderators Posted September 30, 2003 Do you have a question? Quote Visit...Bassic Software
Moderators Robby Posted October 1, 2003 Moderators Posted October 1, 2003 What is the problem or question that you have? Quote Visit...Bassic Software
atoz Posted October 2, 2003 Author Posted October 2, 2003 (edited) may i show my codes.. Sub ddlTime_Changed(ByVal sender As Object, ByVal e As System.EventArgs) Dim dtTempTime As Date lblErrMsg.Text = lblErrMsg.Text & "in ddltime_selectedchanged" If (ddlChosenDate.SelectedIndex = 0) Then strTempTime = CStr(ddlTimeSlots.SelectedItem.Text) dtTempTime = CDate(strTempTime.Substring(0, 5)) FormatDateTime(dtTempTime, DateFormat.ShortTime) If Not (Request.Cookies("facId") Is Nothing) Then intSelectedFacID = Request.Cookies("facID").Value End If time_date(dtTempTime, intSelectedFacID) check_empty_ddl(ddlChosenDate, "time slot") ddlChosenDate.AutoPostBack = True ddlTimeSlots.AutoPostBack = True End If lblErrMsg.Text = lblErrMsg.Text & "out ddltime_selectedchanged" End Sub Sub time_date(ByVal paraTime As Date, ByVal paraFacID As Integer) If Not (Request.Cookies("FacTotalRows") Is Nothing) Then intFacTotalRows = Request.Cookies("FacTotalRows").Value End If If Not (paraFacID < 0) Then Response.Cookies("facID").Value = paraFacID Response.Cookies("ErrMsg").Value = "The facility you have selected is invalid. Please re-select." Response.Redirect("facBooking.aspx") Else 'instantiate query string strBookQuery = "SELECT * FROM FacilityBooking where fabfacIDInt = " & paraFacID 'Connect to database, invoking module file mehtod Call updateDataAdapter(strDBPath, strBookQuery, strBookTblName, objConn, objComm, objAdapter, dsBooked) 'set the values of dataTable tblBook = dsBooked.Tables(strBookTblName) 'counting the total no. of rows in dataset, dsFac intBookTotalRows = CInt(tblBook.Rows.Count) For i = 0 To 13 '2 weeks; 14 days dtDate = DateAdd(DateInterval.Day, i, Now()) 'adding day by day to check 'row no.s to transverse through records For y = 0 To intBookTotalRows - 1 'match if dtDate date and selected timeSlot has been booked If (tblBook.Rows(y).Item("fabDateChosenStr") = dtDate And _ tblBook.Rows(y).Item("fabStartTimeStr") = paraTime) Then Exit For 'if yes then Else 'once the last record reached While (y = intBookTotalRows - 1) 'populate dropdownlists ddlChosenDate.Items.Add(CStr(FormatDateTime(dtDate, DateFormat.ShortDate))) Exit For End While End If Next Next End If End Sub Edited October 2, 2003 by Robby Quote
atoz Posted October 2, 2003 Author Posted October 2, 2003 but wat happened is tat the label doesnt even display those text.. i used lblErrMsg.Text to trace the progress of my appn Quote
atoz Posted October 2, 2003 Author Posted October 2, 2003 if i set autopostback = true... then both my ddlChosenDate and ddlTimeSlots will get refreshed and set back to first item... that is: "Select A time" or "Select A date" I am trying to do an online booking by the way... i am looping to check if exact date and time has been booked.. if yes then wont add it to my dropdownlist for users to choose Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.