Solved

syntaz error?

Posted on 2004-08-06
2
209 Views
Last Modified: 2010-04-15

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();
0
Comment
Question by:animated405
2 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 50 total points
ID: 11737508
SqlCommand myCommand= new SqlCommand("up_add", new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
);
myCommand.CommandType=CommandType.StoredProcedure ;
0
 

Author Comment

by:animated405
ID: 11738005

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!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question