protected SqlConnection Conn;
protected string ConnectionString = "server=.; database=ExpatiateAspNet; uid=sa; pwd=";
protected void Page_Load(object sender, EventArgs e)
{
using (Conn = new SqlConnection(ConnectionString))
{
Conn.Open();//打开数据库连接
SqlCommand cmd = new SqlCommand("Proc_UsersAdd", Conn);
cmd.CommandType = CommandType.StoredProcedure;//调用存储过程
cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 50).Value = "pyj";
cmd.Parameters.Add("@UserPwd", SqlDbType.VarChar, 50).Value = "123";
cmd.ExecuteNonQuery();//执行命令
Response.Write("添加数据成功!");
}
}