我尝试使用 sqlparameters 将数据插入数据库,但我无法做到这一点..请帮助我..
a = "insert into Matsamp values(Login_Name,Password,Confirm_Password) values(@LName,@Pswd,@CPassword)";
SqlCommand cm = new SqlCommand(a, con1);
SqlParameter Uparm;
Uparm = new SqlParameter("@LName", SqlDbType.VarChar, 25);
Uparm.Value = TextBox1.Text;
cm.Parameters.Add(Uparm);
string original;
original = TextBox2.Text.Trim();
int h = original.GetHashCode();
string withHash = original;
b1 = Encoding.BigEndianUnicode.GetBytes(withHash);
encrypted = Convert.ToBase64String(b1);
SqlParameter Pparam;
Pparam = new SqlParameter("@Pswd", SqlDbType.VarChar, 300);
Pparam.Value = Convert.ToString(encrypted);
cm.Parameters.Add(Pparam);
SqlParameter CPparm;
CPparm = new SqlParameter("@CPassword", SqlDbType.VarChar, 300);
CPparm.Value = TextBox3.Text;
cm.Parameters.Add(CPparm);
cm.ExecuteNonQuery();
Response.Write("<Script>alert('inserted')</script>");
}
con1.Close();