I'm trying to create a webpage that will allow the user to input a vendor number(text box) and if the number exists populate the form with vendor name, phone and state using a stored procedures. Below you will find the stored procedures and after it my webpage.
Stored Procedures:
SELECT [V_NAME], [V_PHONE], [V_STATE] FROM [VENDOR] WHERE ([V_CODE] = @V_CODE)
vb code:
Protected Sub btnVendor_Click(sender As Object, e As System.EventArgs) Handles btnVendor.Click
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyDataAdapter As SqlDataAdapter
MyConnection = New SqlConnection("server=xx.xx.xx.xx;database=xxx;User ID=xxxx; Password=xxxx")
MyDataAdapter = New SqlDataAdapter("VendorInfo", MyConnection)
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@V_CODE", txtVenNum.Text))
MyDataAdapter.SelectCommand.Parameters("@V_CODE").Value = Trim(txtVenNum.Text)
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@V_NAME", SqlDbType.NVarChar, 15))
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@V_Phone", SqlDbType.NVarChar, 8))
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@V_State", SqlDbType.NVarChar, 2))
DS = New DataSet()
MyDataAdapter.Fill(DS, "Results")
MyDataAdapter.Dispose()
MyConnection.Close()
lblOutput.Text = DS.Tables("Results").Rows(0).Item(1)
lblout1.Text = DS.Tables("Results").Rows(0).Item(2)
lbloutput2.Text = DS.Tables("Results").Rows(0).Item(3)
End Sub
End Class
Can someone help me out with this please. Thanks in advance.