Solved

syntaz error?

Posted on 2004-08-06
2
205 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
Comment Utility
SqlCommand myCommand= new SqlCommand("up_add", new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
);
myCommand.CommandType=CommandType.StoredProcedure ;
0
 

Author Comment

by:animated405
Comment Utility

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now