Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using @Kapil and @Icarus replies, I was able to get this to work. Thanks for taking the time to help. It pointed me in the correct direction.</p> <p>This is what I ended up with:</p> <pre><code> Protected Sub btnSearch_Click(sender As Object, e As System.EventArgs) Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyDataAdapter As SqlDataAdapter Dim msg As String = "" 'Create a connection to the SQL Server. MyConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("msSQLdb").ConnectionString) 'Create a DataAdapter, and then provide the name of the stored procedure. MyDataAdapter = New SqlDataAdapter("sp_search_all_SQLservers", MyConnection) 'Set the command type as StoredProcedure. MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure 'Create and add a parameter to Parameters collection for the stored procedure. MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@ACTNbr", SqlDbType.VarChar, 10)) MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@WTHNbr", SqlDbType.VarChar, 15)) 'Assign the search value to the parameter. MyDataAdapter.SelectCommand.Parameters("@ACTNbr").Value = tbACTNbr.Text.ToString.Trim MyDataAdapter.SelectCommand.Parameters("@WTHNbr").Value = tbWTHNbr.Text.ToString.Trim 'Create a new DataSet to hold the records. DS = New DataSet() 'Fill the DataSet with the rows returned. MyDataAdapter.Fill(DS, "proc_results") 'Set the data source for the gridview as the DataSet that holds the rows. gv.DataSource = DS.Tables("proc_results").DefaultView For i = 1 To DS.Tables.Count - 1 DS.Tables(0).Merge(DS.Tables(i)) Next msg = DS.Tables(0).Rows.Count &amp; " rows found" gv.Caption = DS.Tables(0).Rows.Count &amp; " rows found" gv.DataSource = DS 'Bind the DataSet to the DataGrid. 'NOTE: If you do not call this method, the DataGrid is not displayed! gv.DataBind() If gv.Rows.Count &lt;&gt; 0 Then gv.Visible = True Else msg = "No data found" End If MyDataAdapter.Dispose() 'Dispose of the DataAdapter. MyConnection.Close() 'Close the connection. DS.Dispose() lblMsg.Text = msg End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload