473,473 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create 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 = ConfigurationSettings.AppSettings["connString"]
this.con = new SqlConnection(this.connString)

this.procedureName = "MyStoredProcName"
this.cmd = new SqlCommand(this.procedureName, this.con)
this.cmd.CommandType = CommandType.StoredProcedure

SqlParameter param
param = this.cmd.Parameters.Add("@MyParameter", SqlDbType.Int)
param.Direction = ParameterDirection.Output;
this.con.Open()
this.cmd.ExecuteNonQuery()
this.con.Close();
Nov 15 '05 #1
1 1810
Hi Jenny,

Is you stored procedure declared correctly:

CREATE PROC MyStoredProcName
(
@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.Message says?

Cheers,

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

"Jenny C." <an*******@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.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 = ConfigurationSettings.AppSettings["connString"];
this.con = new SqlConnection(this.connString);

this.procedureName = "MyStoredProcName";
this.cmd = new SqlCommand(this.procedureName, this.con);
this.cmd.CommandType = CommandType.StoredProcedure;

SqlParameter param;
param = this.cmd.Parameters.Add("@MyParameter", SqlDbType.Int);
param.Direction = ParameterDirection.Output;
this.con.Open();
this.cmd.ExecuteNonQuery();
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
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...
11
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
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...
1
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...
0
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...
3
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...
5
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...
9
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...
1
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...
0
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,...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.