473,753 Members | 8,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System Error when trying to call Stored Procedure from code

Hi

I am fairly new to .NET, and I am having a hard time to call a stored procedure from C# code in a windows application
I have tested my connection (and login) several time and it is OK. If I try to do a query it works, but when I try to call a stored procedure i get the message "System Error". My code is shown below
Any idea what could be the problem
A million thanks

Jenn
------------------------

this.connString = ConfigurationSe ttings.AppSetti ngs["connString "]
this.con = new SqlConnection(t his.connString)

this.procedureN ame = "MyStoredProcNa me"
this.cmd = new SqlCommand(this .procedureName, this.con)
this.cmd.Comman dType = CommandType.Sto redProcedure

SqlParameter param
param = this.cmd.Parame ters.Add("@MyPa rameter", SqlDbType.Int)
param.Direction = ParameterDirect ion.Output;
this.con.Open()
this.cmd.Execut eNonQuery()
this.con.Close( );
Nov 15 '05 #1
1 1835
Hi Jenny,

Is you stored procedure declared correctly:

CREATE PROC MyStoredProcNam e
(
@MyParameter INT OUTPUT
)
AS
-- the code

if it does, can you wrap the ExecuteNonQuery () call in a try/catch block and
see that the Exception.Messa ge says?

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jenny C." <an*******@disc ussions.microso ft.com> wrote in message
news:11******** *************** ***********@mic rosoft.com...
Hi,

I am fairly new to .NET, and I am having a hard time to call a stored procedure from C# code in a windows application. I have tested my connection (and login) several time and it is OK. If I try to do a query it works, but when I try to call a stored procedure i get
the message "System Error". My code is shown below. Any idea what could be the problem?
A million thanks!

Jenny
-------------------------
this.connString = ConfigurationSe ttings.AppSetti ngs["connString "];
this.con = new SqlConnection(t his.connString) ;

this.procedureN ame = "MyStoredProcNa me";
this.cmd = new SqlCommand(this .procedureName, this.con);
this.cmd.Comman dType = CommandType.Sto redProcedure;

SqlParameter param;
param = this.cmd.Parame ters.Add("@MyPa rameter", SqlDbType.Int);
param.Direction = ParameterDirect ion.Output;
this.con.Open() ;
this.cmd.Execut eNonQuery();
this.con.Close( );

Nov 15 '05 #2

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

Similar topics

0
4277
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the experts here agree with the following? Would they add any other points? 1. If the shop standard calls for logging of application errors, a stored procedure should log any error that it encounters immediately upon detecting it and then return to the...
11
3490
by: ColdCanuck | last post by:
Greetings! I am VERY new to DB2 but not Orable, Sybase and SQL Server. I am trying to call a stored procedure via VB 6 and ADO/OLEDB. But when I try to execute
0
7147
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE TRIGGER statement.) I've also defined a SQL stored proc, and the trigger is set to call this SP. I've posted the simplified source below. I can manually call the stored proc, and the external trigger is created without any errors. However, when I do...
1
4905
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm specifiying my code: The Code used in Visual Studio: Function GetRank(ByVal ID As Integer, ByVal Comp As String, ByVal Sec As String, ByVal iDate As Date) As String 'Dim Ret As Integer
0
1142
by: Diffident | last post by:
Hello Guys, How can I call a SYSTEM stored procedure in ORACLE from my DAL component? I am trying to call in the same way as I would call a normal stored procedure but it is throwing me an error which states that wrong number or type of arguments which is the generic error. I am pretty sure that I am passing the correct number and type of parameters to the procedure. Any ideas?
3
3346
by: tol7481 | last post by:
Hi, I'm trying to deploy a Java stored procedure on DB2 V8 on a Linux box, but I have some problems. I've added to the classpath the following JARs sqllib/java/db2java.zip sqllib/java/db2jcc.jar sqllib/java/db2jcc_license_cu.jar sqllib/java/sqlj.zip
5
8833
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT INTEGER,
9
2948
by: Ratfish | last post by:
I'm getting a "2014:: Commands out of sync; you can't run this command now" error on a php page when I try to call a second stored procedure against a MySQL db. Does anyone know why I might be getting this error? The error doesn't occur on my development box where I use the 'root' db user, but does occur in production where I'm using a non- root user record to establish a connection. I'm essentially opening a connection at the top of...
1
14049
by: preejith | last post by:
Error Code : 1329, No data - zero rows fetched, selected, or processed. MYSQL I am getting the following error while running a stored procedure in mysql5.0 Error Code : 1329 No data - zero rows fetched, selected, or processed. I have an stored procedure SP1 which calls stored procedure SP2 and SP2 calls a function F1. I have run this script from .bat file.
0
9072
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8896
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
9653
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
9421
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,...
1
6869
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
6151
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
4771
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...
1
3395
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
3
2284
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.