G
Guest
I'm trying to get the results of a stored proc (with no input parameters)
into a datagridview. I'm able to get the results into a messagebox but i'm
nor sure how to get them into a DataGridView
Using cn As New SqlConnection(strConn)
Try
cn.Open()
Catch ex As Exception
MessageBox.Show("Connect Attempt Failed")
MessageBox.Show(ex.Message.ToString)
End Try
Dim cmd As New SqlCommand("sp_TestBilly", cn)
cmd.CommandType = CommandType.StoredProcedure
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
'Do While rdr.Read()
' MessageBox.Show(rdr(0) & " " & rdr(1) & " " & rdr(2) & " "
& rdr(3) & " " & rdr(4) & " " & rdr(5) & " " & rdr(6), "sp_BillyTest")
'Loop
'rdr.Close()
datagridview1.DataSource=***here's where I can't get the code
right****
cn.Close()
End Using
End Sub
--
Billy Rogers
Dallas,TX
Currently Using SQL Server 2000, Office 2000 and Office 2003
into a datagridview. I'm able to get the results into a messagebox but i'm
nor sure how to get them into a DataGridView
Using cn As New SqlConnection(strConn)
Try
cn.Open()
Catch ex As Exception
MessageBox.Show("Connect Attempt Failed")
MessageBox.Show(ex.Message.ToString)
End Try
Dim cmd As New SqlCommand("sp_TestBilly", cn)
cmd.CommandType = CommandType.StoredProcedure
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
'Do While rdr.Read()
' MessageBox.Show(rdr(0) & " " & rdr(1) & " " & rdr(2) & " "
& rdr(3) & " " & rdr(4) & " " & rdr(5) & " " & rdr(6), "sp_BillyTest")
'Loop
'rdr.Close()
datagridview1.DataSource=***here's where I can't get the code
right****
cn.Close()
End Using
End Sub
--
Billy Rogers
Dallas,TX
Currently Using SQL Server 2000, Office 2000 and Office 2003