|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Multiple executescalar()I have a DataGrid that on every line I need to get four records from a data base as I scroll thorugh the records. THanks to Steve I can get the four records with ExeuteScalar but the speed is very slow now. In my code I do four conn.open and four conn.close with four different OleDb Commands and four different SQL statements. If there a way to setup one and keep changing the SQL statement and than closing it at the end. I'm posting one of the four here: If myDV(rowIndex)("SDSNo").ToString <> "" Then Dim conn3 As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\BMActivityReporting.mdb;Persist Security Info=False") Dim sSQL3 As String = "select UserName FROM UserTable WHERE UserNo='" & myDV(rowIndex)("SDSNo").ToString() & "'" Dim da3 As New System.Data.OleDb.OleDbCommand(sSQL3, conn3) conn3.Open() Try da3.ExecuteScalar() Me.SDS.Text = da3.ExecuteScalar.ToString() Catch ex As System.Data.OleDb.OleDbException Dim errorMessages As String Dim i As Integer For i = 0 To ex.Errors.Count - 1 errorMessages += "Index #" & i.ToString() & ControlChars.Cr _ & "Message: " & ex.Errors(i).Message & ControlChars.Cr _ & "NativeError: " & ex.Errors(i).NativeError & ControlChars.Cr _ & "Source: " & ex.Errors(i).Source & ControlChars.Cr _ & "SQLState: " & ex.Errors(i).SQLState & ControlChars.Cr Next i MsgBox(errorMessages) Finally conn3.Close() End Try End If If myDV(rowIndex)("SDSNo").ToString() = "" Then Me.SDS.Text = "" End If Thanks in advance, Steve Stephen,
Using an execute scalar to get a part of data for a datagrid is strange. It is absolute not bounded than anymore. Probably would a related datatable do its job better, so reply to your original problem, or give us the problem again. Cor Show quoteHide quote "Stephen Plotnick" <splotn***@groupcbf.com> schreef in bericht news:MeednS4OSpFlzifZnZ2dnUVZ_sednZ2d@giganews.com... >I think I have a speed issue I'd like to resolve. > > I have a DataGrid that on every line I need to get four records from a > data base as I scroll thorugh the records. > > THanks to Steve I can get the four records with ExeuteScalar but the speed > is very slow now. > > In my code I do four conn.open and four conn.close with four different > OleDb Commands and four different SQL statements. > > If there a way to setup one and keep changing the SQL statement and than > closing it at the end. > > I'm posting one of the four here: > > If myDV(rowIndex)("SDSNo").ToString <> "" Then > > Dim conn3 As New > System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data > source=C:\BMActivityReporting.mdb;Persist Security Info=False") > > Dim sSQL3 As String = "select UserName FROM UserTable WHERE UserNo='" & > myDV(rowIndex)("SDSNo").ToString() & "'" > > Dim da3 As New System.Data.OleDb.OleDbCommand(sSQL3, conn3) > > conn3.Open() > > Try > > da3.ExecuteScalar() > > Me.SDS.Text = da3.ExecuteScalar.ToString() > > Catch ex As System.Data.OleDb.OleDbException > > Dim errorMessages As String > > Dim i As Integer > > For i = 0 To ex.Errors.Count - 1 > > errorMessages += "Index #" & i.ToString() & ControlChars.Cr _ > > & "Message: " & ex.Errors(i).Message & ControlChars.Cr _ > > & "NativeError: " & ex.Errors(i).NativeError & ControlChars.Cr _ > > & "Source: " & ex.Errors(i).Source & ControlChars.Cr _ > > & "SQLState: " & ex.Errors(i).SQLState & ControlChars.Cr > > Next i > > MsgBox(errorMessages) > > Finally > > conn3.Close() > > End Try > > End If > > If myDV(rowIndex)("SDSNo").ToString() = "" Then > > Me.SDS.Text = "" > > End If > > > > > > Thanks in advance, > > Steve > >
Resume next in VB.NET ?
Database Connection Problem. Please Help AS400 - Ado.Net from Vb.Net Slow Query Times Can I make my Form visible during a debug session? ddl selectedindexchanged not firing on first item - I'm using a dataset to populate the ddl object reference not set to an instance of an object error Is this a bug: 2.2 - 0.4 = 1.8 but 1.2 - 0.4 = 0.8000001 ? Commenting Out Controls In HTML View Convert Array of Objects to Generics List? LIKE % % with inner join |
|||||||||||||||||||||||