谁能给一个用connection对象调用带 输入和输出参数 的数据库存储过程 的实例。谢谢。

解决方案 »

  1.   


    public void Mothed(int Person_ID)
        {
            try
            {
                string storedProcName = "PersonInfo_BulkDelete";
                string connectionString = ConfigurationSettings.AppSettings["ConnectionStrings"];
                SqlConnection connect = new SqlConnection(connectionString);
                SqlCommand command = new SqlCommand(storedProcName, connect);
                command.CommandType = CommandType.StoredProcedure;
                connect.Open();
                SqlParameter sqlparam = new SqlParameter("@Person_ID", SqlDbType.Int, 4);
                sqlparam.Value = Person_ID;
                command.Parameters.Add(sqlparam);
                command.ExecuteNonQuery();
                command.Dispose();
                connect.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {        }
        }
      

  2.   


    string connectionString = ConfigurationSettings.AppSettings["ConnectionStrings"];
    这个是在web.config里写链接库字符串,可以这样写
    string connectionString = "Data Source=192.168.0.123;User ID=sa;Password=sa;"