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