T
TG
Hi!
I am using VB 2008 with SQL Server 2000 and SQL Server 2005 (depending
which server the user selects to connect to).
I have a listbox in which the user select the server to connect to.
Another listbox that shows the databases in that particular server.
Another listbox with the filesets from the selected database above.
When the user clicks on button 3, I want the datagridview to populate
data from a stored procedure passing 2 parameters in sql server.
At the moment the datagridview does not populate anything, neither
does it throw an error message. I have no clue what is wrong and I am
new to VB.
Your help will be greatly appreciated.
Thanks!
Tammy
Code for button 3:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim cn As New SqlConnection("Data Source=" &
lstServers.SelectedValue & ";Initial Catalog=" &
lstDatabases.SelectedValue & ";Integrated Security=SSPI")
Dim cmd As New SqlCommand("usp_DR_Spam_BB_Search_get_recs",
cn)
Dim dt As New DataTable()
cmd.CommandTimeout = 0
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@Matter",
lstDatabases.SelectedItem)
cmd.Parameters.AddWithValue("@FileSet",
lstFileSets.SelectedItem)
cn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
DataGridView1.DataSource = reader
End Sub
I am using VB 2008 with SQL Server 2000 and SQL Server 2005 (depending
which server the user selects to connect to).
I have a listbox in which the user select the server to connect to.
Another listbox that shows the databases in that particular server.
Another listbox with the filesets from the selected database above.
When the user clicks on button 3, I want the datagridview to populate
data from a stored procedure passing 2 parameters in sql server.
At the moment the datagridview does not populate anything, neither
does it throw an error message. I have no clue what is wrong and I am
new to VB.
Your help will be greatly appreciated.
Thanks!
Tammy
Code for button 3:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim cn As New SqlConnection("Data Source=" &
lstServers.SelectedValue & ";Initial Catalog=" &
lstDatabases.SelectedValue & ";Integrated Security=SSPI")
Dim cmd As New SqlCommand("usp_DR_Spam_BB_Search_get_recs",
cn)
Dim dt As New DataTable()
cmd.CommandTimeout = 0
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@Matter",
lstDatabases.SelectedItem)
cmd.Parameters.AddWithValue("@FileSet",
lstFileSets.SelectedItem)
cn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
DataGridView1.DataSource = reader
End Sub