I'm surprised there isn't any errors because you specified the wrong stored procedure name and variable name.
In the code you have "StoredProcedure" and "@GlobalNumberID".
Yet, the storeprocedure is defined as:
Code:
ALTER PROCEDURE StoredProcedure1
(
@GNumber BigInt
)
Also, 'using' blocks help with immediately cleaning up resources (which is very important when working with databases).
Rewriting the code to use using blocks looks like:
Code:
using( var cn = new SqlConnection( ... ) )
{
using( var cmd = cn.CreateCommand() )
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "StoredProcedure1";
cmd.Parameters.AddWithValue( "@GNumber ", Convert.ToInt64(textBox1.Text) );
cn.Open();
cmd.ExecuteNonQuery();
}
}
The using blocks free up the SqlConnection and SqlCommand objects right at the closing braces.
You might also notice I've called AddWithValue for the sproc variable. This method is smart enough to realize the value is an Int64.
Bookmarks