System Error when trying to call Stored Procedure from code

G

Guest

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();
 
H

Hussein Abuthuraya[MSFT]

Jenny,

Wrap the ExecuteNonQuery call in a Try... Catch... block and display the Exception message (Check the docs for the syntax). This message would be more informative and
it may lead you to the solution. If not, please post the Exception message and the stored procedure script.


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top