|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
sqlreader Do...while problemdrBranchForm = sqldatareader
For Each drBranch In dtUserBranch Do While drBranchForm.Read .......... Problem (A) Loop Next I found that the datarreader only loop onces , ?? How can I make it restart the sqldatareader ??? Thanks Hi,
Here is an working example. Would have to see more of your code to figure out the problem you are having. Dim conn As SqlConnection Dim strConn As String Dim drCustomer As SqlDataReader Dim daCustomer As SqlDataAdapter Dim cmd As SqlCommand Dim ds As New DataSet strConn = "Server = " & Environment.MachineName & ";" strConn &= "Database = NorthWind;" strConn &= "Integrated Security = SSPI;" conn = New SqlConnection(strConn) cmd = New SqlCommand("Select * from Customers", conn) conn.Open() drCustomer = cmd.ExecuteReader Do While drCustomer.Read Trace.WriteLine(drCustomer.Item("CustomerID").ToString) Loop conn.Close() Ken ----------------------------------- "Agnes" <ag***@dynamictech.com.hk> wrote in message For Each drBranch In dtUserBranchnews:%232YzbGuMFHA.3164@TK2MSFTNGP10.phx.gbl... drBranchForm = sqldatareader Do While drBranchForm.Read .......... Problem (A) Loop Next I found that the datarreader only loop onces , ?? How can I make it restart the sqldatareader ??? Thanks Do you know if you have many transaction you need to call NextResult ??
again, need to provide us more code please ^_^ From http://www.developmentnow.com/g/38_2005_3_0_0_371001/sqlreader-Do---while-problem.htm Posted via DevelopmentNow.com Groups http://www.developmentnow.com However you can just try something like this.
Dim drBranchForm As SqlDataReader drBranchForm = myCommand.ExecuteReader() ' Always call Read before accessing data. While drBranchForm.Read() Console.WriteLine(( drBranchForm.GetInt32(0) & ", " & drBranchForm.GetString(1))) End While ' always call Close when done reading. drBranchForm.Close() take out the FOR EACH loop first. Hope this can help ^_^ From http://www.developmentnow.com/g/38_2005_3_0_0_371001/sqlreader-Do---while-problem.htm Posted via DevelopmentNow.com Groups http://www.developmentnow.com
Timer1_Elapsed problem.
Locate MessageBox over Window Error with Custom Control ListViewImageList keeps bitmap locked after disposing what if the database connection isn't close MaskedEdit Control Friend WithEvents Upload file programmatically DataGrid OnPaint/? -How Do I Draw A GDI Type Circle On Top Of A DataGrid FileSystemWatcher: Fix for lowercase? |
|||||||||||||||||||||||