G
Guest
I'm using this coding to get 2 resultsets thru datareader and then load them
into 2 datatables and bind the datatables to datagridviews. But
sdrGrid.NextResult() is returning false for some reason. Is that possible
the connection is closed?
Dim strConn As String = "Server=localhost;Database=northwind;" + _
"Integrated Security=SSPI"
Dim cnnNwind As SqlConnection = New SqlConnection(strConn)
Try
Dim strSql As String = "select * from customers;select * from
products"
Dim cmdGrid As New SqlCommand(strSql, cnnNwind)
cmdGrid.CommandType = CommandType.Text
cnnNwind.Open()
Dim sdrGrid As SqlDataReader = cmdGrid.ExecuteReader
Dim dt1 As New DataTable
dt1.Load(sdrGrid)
DGVP.DataSource = dt1
Dim dt2 As New DataTable
If sdrGrid.NextResult() = True Then
dt2.Load(sdrGrid)
DGVC.DataSource = dt2
End If
Catch exc As Exception
MsgBox(exc.Message)
Finally
cnnNwind.Close()
End Try
into 2 datatables and bind the datatables to datagridviews. But
sdrGrid.NextResult() is returning false for some reason. Is that possible
the connection is closed?
Dim strConn As String = "Server=localhost;Database=northwind;" + _
"Integrated Security=SSPI"
Dim cnnNwind As SqlConnection = New SqlConnection(strConn)
Try
Dim strSql As String = "select * from customers;select * from
products"
Dim cmdGrid As New SqlCommand(strSql, cnnNwind)
cmdGrid.CommandType = CommandType.Text
cnnNwind.Open()
Dim sdrGrid As SqlDataReader = cmdGrid.ExecuteReader
Dim dt1 As New DataTable
dt1.Load(sdrGrid)
DGVP.DataSource = dt1
Dim dt2 As New DataTable
If sdrGrid.NextResult() = True Then
dt2.Load(sdrGrid)
DGVC.DataSource = dt2
End If
Catch exc As Exception
MsgBox(exc.Message)
Finally
cnnNwind.Close()
End Try