参数化查询 '(@mbox varchar(150),@age int,@phone varchar(50),@address varchar' 需要参数 '@mbox',但未提供该参数。
public bool upinform()
{
conn = new SqlConnection(connstr);
string sql = "update admin set mailbox=@mbox,age=@age,phone=@phone,address=@address where username=@uname";
try
{
conn.Open();
SqlCommand comm = new SqlCommand(sql, conn);
comm.Parameters.Add("@mbox", SqlDbType.VarChar, 150);
comm.Parameters.Add("@age", SqlDbType.Int);
comm.Parameters.Add("@phone",SqlDbType.VarChar,50);
comm.Parameters.Add("@address",SqlDbType.VarChar,250);
comm.Parameters.Add("@uname",SqlDbType.VarChar,16);
comm.Parameters[0].Value = MailBox;
comm.Parameters[1].Value = Age;
comm.Parameters[2].Value = Phone;
comm.Parameters[3].Value = Address;
comm.Parameters[4].Value= UserName;
int rows = Convert.ToInt16(comm.ExecuteScalar());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
catch (System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
}
finally
{
conn.Close();
}
}
public partial class hout : System.Web.UI.Page
{
private string eid = "";
protected void Page_Load(object sender, EventArgs e)