Accepting parameter and Display on a DataGridView ? Please Guidance !

elistech

New member
Joined
Jul 26, 2006
Messages
2
Programming Experience
Beginner
Hi,
I have following:
Stored Procedure (tested working)
DataGridView
My connection String, Dataset, Databinding is all taking care of.
I can display the data on the DataGridView without a parameter just fine but when I try to accept a parameter through a textbox it doesn't do anything.
I want to enter the ID number(parameter) to the text box then click on search button and display the data on my DataGridView.
I would appreciate any guidance and help - Thanks - Elis
My Code is below:
Public Class Form1

Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchButton.Click

BDataGridView()

End Sub

Private Sub BDataGridView()
' Set up Connection
Dim GridConStr As String = "server=WDBSSD05;User ID=budget; pwd=embudget;database=BudgetPayment;"
Dim cnGrid As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection
' Set up command object
Dim cmdGrid As New System.Data.SqlClient.SqlCommand("usp_Display_BudgetPayment_Detail", cnGrid)
cmdGrid.CommandType = CommandType.StoredProcedure
cmdGrid.Parameters.Add("@SoldToID", SqlDbType.VarChar, 6).Value = SAPIDTextBox.Text()
' Set up DataReader
Dim rdGrid As System.Data.SqlClient.SqlDataReader
' Connect
cnGrid.ConnectionString = GridConStr
cnGrid.Open()
rdGrid = cmdGrid.ExecuteReader()
If rdGrid.HasRows = True Then
DataGridView.DataSource = EMBudgetPaymentDataSet.usp_Display_BudgetPayment_Detail
End If
cnGrid.Close()
End Sub
End Class
 
Back
Top