Passing parameters to a sql stored procedure
I'm trying to call a stored procedure in the Northwind database with a single input parameter but I'm having trouble with the correct syntax. The code I've got is below. I've commented out a couple attempts which caused errors. The errors I think were reported as syntax errors at run time. So I think the code was passed to SQL which looked at it, had a laugh and returned an error. Any ideas?
Dim conn As New SqlConnection
conn.ConnectionString = "Trusted_Connection=yes;Addr=P2000;Initial Catalog=Northwind"
conn.Open()
Dim comm As New SqlCommand
comm.Connection = conn
comm.CommandType = CommandType.StoredProcedure
comm.CommandText = "CustOrdersDetail @Cust"
'comm.Parameters.Add("@Cust", SqlDbType.Int, 10248)
'comm.Parameters("Cust").Value = 10248
Dim dreader As SqlDataReader
dreader = comm.ExecuteReader()
While dreader.Read()
TextBox1.Text = TextBox1.Text + dreader("ProductName").ToString + vbCrLf
End While
|