Link to home
Start Free TrialLog in
Avatar of animated405
animated405

asked on

syntaz error?


new to c#. I have a methof that just does some work so it does not return anything. when i load the page I get this error:

System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'up_add'.

and it highlights the myCommand.ExecuteNonQuery; line

what's wrong here, code below...thanks in advance!!


SqlCommand myCommand = new SqlCommand();
                  myCommand.Connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
                  myCommand.CommandText = "up_add";
                  
                  myCommand.Parameters.Add("@session_id", SqlDbType.Int).Value = SessionID;
                  myCommand.Parameters.Add ("@product_id", SqlDbType.Int).Value = ProductID;

                  myCommand.Connection.Open();
                  myCommand.ExecuteNonQuery();
                  myCommand.Connection.Close();
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of animated405
animated405

ASKER


Ok, I get it. If I want to pass in the actual sql then I would use the commandtext, I was confusing that with something else.

thanks very much!!