Hi Everyone,
Please help me on this one. I have the following function:
Public Sub SearchFor(ByRef mType As Module1.SearchForType, ByRef mValue As
String)
On Error GoTo Err_Handler
Dim Proc As String
Dim conStr as string = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=Inventory;Data Source=SQLSERVER;"
Dim con as SqlConnection = new SqlConnection(conStr)
Dim cmd as SqlCommand
Select Case mType
Case Module1.SearchForType.ByBarCode
cmd = new SqlCommand("nf_GetInventoryItem", con)
cmd.Parameters.Add("@BarCodeId", sqldbtype.Int).Value = Val(CStr(mValue))
Case Module1.SearchForType.ByProductName
cmd = new SqlCommand("nf_GetInventoryByProductName", con)
cmd.Parameters.Add("@ProductName", sqldbtype.NVarChar, 25 ).Value = mValue
Case Module1.SearchForType.ByModelNumber
cmd = new SqlCommand("nf_GetInventoryByModelNumber", con)
cmd.Parameters.Add("@ModelNumber", sqldbtype.NVarChar, 30 ).Value = mValue
End Select
Dim ds as DataSet = new DataSet("SearchForQuery")
dim da as SqlDataAdapter
da = new SqlDataAdapter()
da.SelectCommand = cmd
da.Fill(ds)
PopulateGrid(ds)
Me.Show()
Exit Sub
Err_Handler:
MsgBox(Err.Number & ": " & Err.Description)
End Sub
The problem is that when the code gets to the da.Fill(ds) command, I get a
"Line 1: Incorrect syntax near 'nf_GetInventoryByProductName'." Error. I can
run the query in Studio .Net or Sql Server Enterprise manager and it works
just fine. I'm also feeding the parameter a value that is in the database. I
can run any of the three stored procedures within this function and will get
the same error message(except the sp name is changed to reflect the sp that
was selected). Does this code right? I'm new to the ADO.Net and little things
like this is driving me nuts :( Thanks for any suggestions that you can offer.
Michael