473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ExecuteNonQuery and sp_executesql

Hello there,
I am having problems with a stored procedure. When a use SqlCommand,
SqlParameter and the ExecuteNonQuery method, i get this error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'spSaveFormRequest'.

(1 row(s) affected)

The code in the Sql Profiler generated by the ExecuteNonQuery method is
as follows:

declare @P1 varchar(36)
set @P1=NULL
exec sp_executesql N'spSaveFormRequest',
N'@frmId varchar(36),@frmName varchar(32),@frmNameFra
varchar(32),@frmXmlConfigurationFile varchar(16),@frmInUse bit,@catId
varchar(36),@frmNewId varchar(36) output',
@frmId = '568a0a56-5559-4a6f-8023-89f7efea2696',
@frmName = 'Headsets replacement',
@frmNameFra = '',
@frmXmlConfigurationFile = NULL,
@frmInUse = 1,
@catId = '063da375-f39c-402d-b6a3-5a491360c99d', @frmNewId = @P1 output
select @P1

The c# code is
conn = new SqlConnection(this.connectionString);
command = new SqlCommand("spSaveFormRequest", conn);
conn.Open();

command.Parameters.Add("@frmId", SqlDbType.VarChar,
36).Value = frmId;
command.Parameters.Add("@frmName", SqlDbType.VarChar,
32).Value = frmName;
command.Parameters.Add("@frmNameFra", SqlDbType.VarChar,
32).Value = frmNameFra;
command.Parameters.Add("@frmXmlConfigurationFile",
SqlDbType.VarChar, 16).Value = xmlFile;
command.Parameters.Add("@frmInUse", SqlDbType.Bit).Value =
frmInUse;
command.Parameters.Add("@catId", SqlDbType.VarChar,
36).Value = catId;

SqlParameter frmNewId = new SqlParameter("@frmNewId",
SqlDbType.VarChar, 36);
frmNewId.Direction = ParameterDirection.Output;

command.Parameters.Add(frmNewId);

command.ExecuteNonQuery();

newid = command.Parameters["@frmNewId"].Value.ToString();

I am not sure what I am doing wrong.

Could someone perhaps help me with the error?
I am using Sql Server 2000, Framework 2.0

thanks in advance

*** Sent via Developersdex http://www.developersdex.com ***
Aug 25 '08 #1
1 6337
Nevermind....

I have forgoten to set the CommandType to StoredProcedure

Thanks,
*** Sent via Developersdex http://www.developersdex.com ***
Aug 25 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cliverama | last post by:
help! fried brains.... asp calling a sqlserver7 stored proc which dynamically builds a sqlstatement & passes it to sp_executesql asp page gives the operation not allowed when object is closed...
1
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
3
by: thomson | last post by:
Hi all, Can sp_executesql used inside a user defined function, i tried but it has compiled well, but when i call the functio it shows Only functions and extended stored procedures can be executed...
1
by: LineVoltageHalogen | last post by:
Greetings All, currentley there is a heated discussion in my place of work over which method is better/more efficient for simple selects. Background: 1.) Simple Application that uses sql server...
7
by: LineVoltageHalogen | last post by:
Greetings All, I have a very large query that uses dynamic sql. The sql is very large and it requires it to be broken into three components to avoid the nvarchar(4000) issue: SET @v_SqlString(...
3
by: elRoyFlynn | last post by:
This is a odd problem where a bad plan was chosen again and again, but then not. Using the profiler, I identified an application-issued statement that performed poorly. It took this form: ...
1
by: Matik | last post by:
Hi to all, Probably I'm just doing something stupid, but I would like you to tell me that (if it is so), and point the solution. There ist the thing: I' having a sp, where I call other sp...
1
by: satishchandrat | last post by:
Hi, This is regarding the sp_executesql and the sql statement parameter, in processing a dynamic SQL on SQL Server 2000, in my stored procedure. I have my SQL string exeeding more than 4000...
5
by: Yash | last post by:
Hi, I am using SQL 2000 SP4. I have compared 2 scenarios: Scenario 1: insert into #bacs_report SELECT ..... WHERE <conditions>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.