Solved

syntaz error?

Posted on 2004-08-06
2
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to repeat the data 4 43
Problem to Office 1 66
How to force output to ascii 2 61
I'm looking for a dynamic length jQuery/javascript currency editor mask? 2 62
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.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 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