62,177
社区成员
发帖
与我相关
我的任务
分享
//连接字符串
string strConnection = "some connection string";
//存储过程名
string strSql = "store procedure name";
SqlConnection objConnection = new SqlConnection(strConnection);
SqlCommand objCommand = new SqlCommand(strSql, objConnection);
//定义访问方式为存储过程
objCommand.CommandType = CommandType.StoredProcedure;
//设定参数,略
try
{
objConnection.Open();
objCommand.ExecuteNonQuery();
}
catch
{
}
finally
{
if (objConnection.State = ConnectionState.Open)
{
objConnection.Close();
}
}