时间:2021-07-01 10:21:17 帮助过:4人阅读
调用参数存储存储过程,有返回值
sql 数据库中的额调用 exec DCEMREMRTEMPLATE101 ‘新建目录’,2;
sql程序代码调用
//有参数存储过程
string connecting = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=DCEMR";
SqlConnection theConnect = new SqlConnection(connecting);
theConnect.Open();
SqlCommand theCommand = theConnect.CreateCommand();
theCommand.CommandText = "DCEMREMRTEMPLATE101";
theCommand.CommandType = CommandType.StoredProcedure;
theCommand.Parameters.Add("@filename",SqlDbType.NVarChar);
theCommand.Parameters["@filename"].Value = "新建目录";
theCommand.Parameters.Add("@Rowcount", SqlDbType.Int);
theCommand.Parameters["@Rowcount"].Direction = ParameterDirection.Output;
//theCommand.Parameters["@Rowcount"].Value = 2;
//theCommand.ExecuteNonQuery();
object ss = theCommand.ExecuteScalar();
//MessageBox.Show( theCommand.Parameters["@Rowcount"].Value.ToString());
SqlDataReader theReader = theCommand.ExecuteReader();
while (theReader.Read())
{
string xx = theReader.GetString(0).ToString();
}
theConnect.Close();
存储过程具体过程以及sql数据库调用和程序代码调用
标签: