SqlCommand CommandTimeout Property
The time in seconds to wait (timeout) for the command to execute. The default is 30 seconds.
A value of 0 indicates no limit and will wait indefinitely until command is executed.
Example:
SqlConnection con = new SqlConnection("connString");
SqlCommand com = new SqlCommand("exec your_stored_procedure", con);
com.CommandTimeout = 60;
A value of 0 indicates no limit and will wait indefinitely until command is executed.
Example:
SqlConnection con = new SqlConnection("connString");
SqlCommand com = new SqlCommand("exec your_stored_procedure", con);
com.CommandTimeout = 60;
SqlParameter
Represents a parameter to a SqlCommand and optionally its mapping to DataSet columns
Represents a parameter to a SqlCommand and optionally its mapping to DataSet columns
Example:
SqlCommand myCommand = new SqlCommand("dbo.[sp_copy]", connString);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@ret_id", SqlDbType.Int);
param.Direction = ParameterDirection.ReturnValue;myCommand.Parameters.Add(param);
param = new SqlParameter("@Source", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = asset_id;
myCommand.Parameters.Add(param);
myCommand.ExecuteNonQuery();
id = Convert.ToInt32(myCommand.Parameters[0].Value);
Niciun comentariu:
Trimiteți un comentariu