nolc
June 10th, 2002, 04:37 PM
Hello!
Does anyone have a clue on how to use DataReader to insert data into a DataGrid!? Is this worth figuring out OR should I just use a DataSet? I figured if I could use a DataReader on all data that would just be displayed and not editted...it would make my application more efficient. Is this true? OR are DataReaders basically just used with Web Forms? Please help!
Thanks again!
Sub DisplayUnassignedOrders(ByVal frm As frmMain)
cmdString = "spSELECTUnassignedOrders"
SQLconn = New SqlConnection(connString)
Dim cmdTemp As New SqlCommand(cmdString, SQLconn)
Dim drTemp As SqlDataReader, dtTemp As DataTable, dsTemp As DataSet
Dim obTemp As Object()
SQLconn.Open()
drTemp = cmdTemp.ExecuteReader(CommandBehavior.CloseConnection)
If (drTemp.Read()) Then
drTemp.Close()
SQLconn.Open()
drTemp = cmdTemp.ExecuteReader(CommandBehavior.CloseConnection)
frm.DataGrid1.DataSource = drTemp
frm.DataGrid1.DataBindings()
'While (drTemp.Read())
'frm.DataGrid1.DataBindings()
'frm.DataGrid1.Item(0, 0) = drTemp.Item(0)
'MessageBox.Show(drTemp.Item(0))
'End While
Else
MessageBox.Show("DataReader not available")
End If
drTemp.Close()
End Sub
Does anyone have a clue on how to use DataReader to insert data into a DataGrid!? Is this worth figuring out OR should I just use a DataSet? I figured if I could use a DataReader on all data that would just be displayed and not editted...it would make my application more efficient. Is this true? OR are DataReaders basically just used with Web Forms? Please help!
Thanks again!
Sub DisplayUnassignedOrders(ByVal frm As frmMain)
cmdString = "spSELECTUnassignedOrders"
SQLconn = New SqlConnection(connString)
Dim cmdTemp As New SqlCommand(cmdString, SQLconn)
Dim drTemp As SqlDataReader, dtTemp As DataTable, dsTemp As DataSet
Dim obTemp As Object()
SQLconn.Open()
drTemp = cmdTemp.ExecuteReader(CommandBehavior.CloseConnection)
If (drTemp.Read()) Then
drTemp.Close()
SQLconn.Open()
drTemp = cmdTemp.ExecuteReader(CommandBehavior.CloseConnection)
frm.DataGrid1.DataSource = drTemp
frm.DataGrid1.DataBindings()
'While (drTemp.Read())
'frm.DataGrid1.DataBindings()
'frm.DataGrid1.Item(0, 0) = drTemp.Item(0)
'MessageBox.Show(drTemp.Item(0))
'End While
Else
MessageBox.Show("DataReader not available")
End If
drTemp.Close()
End Sub