Solved

syntaz error?

Posted on 2004-08-06
2
207 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS subreport with parameter 3 33
Printing 1 51
Hey!!!! 1 21
I need help with Crystal Report's Parameter Prompt Form 2 11
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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