473,804 Members | 3,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 'spSaveFormRequ est'.

(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'spSaveFormReq uest',
N'@frmId varchar(36),@fr mName varchar(32),@fr mNameFra
varchar(32),@fr mXmlConfigurati onFile varchar(16),@fr mInUse bit,@catId
varchar(36),@fr mNewId varchar(36) output',
@frmId = '568a0a56-5559-4a6f-8023-89f7efea2696',
@frmName = 'Headsets replacement',
@frmNameFra = '',
@frmXmlConfigur ationFile = NULL,
@frmInUse = 1,
@catId = '063da375-f39c-402d-b6a3-5a491360c99d', @frmNewId = @P1 output
select @P1

The c# code is
conn = new SqlConnection(t his.connectionS tring);
command = new SqlCommand("spS aveFormRequest" , conn);
conn.Open();

command.Paramet ers.Add("@frmId ", SqlDbType.VarCh ar,
36).Value = frmId;
command.Paramet ers.Add("@frmNa me", SqlDbType.VarCh ar,
32).Value = frmName;
command.Paramet ers.Add("@frmNa meFra", SqlDbType.VarCh ar,
32).Value = frmNameFra;
command.Paramet ers.Add("@frmXm lConfigurationF ile",
SqlDbType.VarCh ar, 16).Value = xmlFile;
command.Paramet ers.Add("@frmIn Use", SqlDbType.Bit). Value =
frmInUse;
command.Paramet ers.Add("@catId ", SqlDbType.VarCh ar,
36).Value = catId;

SqlParameter frmNewId = new SqlParameter("@ frmNewId",
SqlDbType.VarCh ar, 36);
frmNewId.Direct ion = ParameterDirect ion.Output;

command.Paramet ers.Add(frmNewI d);

command.Execute NonQuery();

newid = command.Paramet ers["@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 6375
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
4867
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 error this is the asp code: Set connInc= server.CreateObject("ADODB.Connection") connInc.Open "DSN=db_database;User ID=userid;Password=xxxxxx" Set rsInc= server.CreateObject("ADODB.Recordset")
1
38593
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
3
7439
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 from within a function. What i have went wrong Thanks in advance
1
460
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 for backened db. 2.) The application is only inserting and selecting data from the db. 3.) The developers want to use sp_executesql for simple selects and the dba's want to use a stored proc. >From my reading it seems that sp_executesql has a...
7
7896
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( N'') SET @v_SqlString2( N'')
3
10367
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: exec sp_executesql N'SELECT col1, col2 FROM t1 WHERE (t2= @Parm1)', N'@Parm1 int', @Parm1 = 8609 t2 is a foreign key column, and is indexed.
1
8344
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 inside. The only problem is, the name of this inside sp is builded variously, and executed over sp_executesql:
1
8257
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 characters. The sp_executesql expects its parameters to be declared as nvarchar/ntext. ntext cannot be declared for a local variable and nvarchar has a maximum limit of 4000 characters. The following was the original approach. ===============
5
3531
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>
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.