Calling stored procedures

  • Thread starter Thread starter Topshot Systems
  • Start date Start date
T

Topshot Systems

I must be missing something simple, but being new to .Net I wouldn't
be surprised. I'm using CF 2.0. I keep getting error 66 invalid syntax
near "mrs..." when the ExecuteNonQuery fires. I've tried "dbo." in
front of the sproc name also.

Using conSql As New SqlConnection(strConnString)

Using sqlUpdateOrder As New
SqlCommand("mrs_update_order", conSql)

sqlUpdateOrder.Parameters.AddWithValue("@char_user", strUsername)

sqlUpdateOrder.Parameters.AddWithValue("@char_order",
lstOrders.SelectedItem.ToString)

Try
conSql.Open()

Dim intCnt As Integer =
sqlUpdateOrder.ExecuteNonQuery()
If intCnt = 0 Then lblStatus.Text = "This
order was already accepted by someone else."

Catch errSql As SqlException

DisplaySQLErrors(errSql)

Finally

conSql.Close()
End Try
End Using
End Using


I had been using the actual SQL command (see sproc code below) that
was made with the above 2 parameter values, which worked just fine,
and then just started moving them to stored procedures. This was the
first one and I haven't had any success yet.

The sproc is very simple:
procedure [dbo].[mrs_update_order]
(
@char_user varchar(50),
@char_order varchar(815)
)
as
begin
UPDATE rawmaterial
SET status = 'A', acceptdate = getdate(), acceptedby = @char_user
WHERE status = 'O' AND orderdetail = @char_order
end

Do I HAVE to use an adapter when using parameters or something?
 
Dans :
Topshot Systems écrivait :
I must be missing something simple, but being new to .Net I wouldn't
be surprised. I'm using CF 2.0. I keep getting error 66 invalid syntax
near "mrs..." when the ExecuteNonQuery fires. I've tried "dbo." in
front of the sproc name also.

Using conSql As New SqlConnection(strConnString)

Using sqlUpdateOrder As New
SqlCommand("mrs_update_order", conSql)

You didn't set the CommandType property of the command.
(StoredProcedure)
 
Dans :Topshot Systems écrivait :




You didn't set the CommandType property of the command.
(StoredProcedure)

That would be it. I knew it had to be simple. Merci!
 
Back
Top