我这一段asp.net程序怎么运行后输入数据,数据库里没有?
来源:百度知道 编辑:UC知道 时间:2024/06/09 00:13:57
{
SqlConnection Conn = new SqlConnection("server=locahost;uid=Administrator;pwd=;database=MyCharRoom");
}
void SubmitData(object obj, EventArgs e)
{
SqlConnection Conn = new SqlConnection("server=locahost;uid=Administrator;pwd=;database=MyCharRoom");
string Sql = "Insert into 用户信息 " +"(用户名, 密码, 确认密码,邮箱,真实姓名,性别,联系方式,自我介绍) values (@yonghuming,@mima,@querenmima,@youxiang,@zhenshixingming,@xingbie,@lianxifangshi,@lianxifangshi,@ziwojieshao)";
SqlCommand sqll=new SqlCommand(Sql,Conn);
try
{
sqll.Connection.Open();
sqll.ExecuteNonQuery();
}
catch(Exception ex)
{
}
sqll.Connection.Close();
(@yonghuming,@mima,@querenmima,@youxiang,@zhenshixingming,@xingbie,@lianxifangshi,@lianxifangshi,@ziwojieshao
这些参数都没有被赋值,所以向数据库中没有插入你想插入的东西
SqlParameter[] pa ={
new SqlParameter"@yonghuming",SqlDbType.VarChar,100),
new SqlParameter("@mima",SqlDbType.VarChar,100),
new SqlParameter("@querenmima",SqlDbType.VarChar,100),
new SqlParameter("@youxiang",SqlDbType.VarChar,100),
new SqlParameter"@zhenshixingming",SqlDbType.VarChar,100),
new SqlParameter "@xingbie",SqlDbType.VarChar,100),
new SqlParameter("@lianxifangshi",SqlDbType.VarChar,100),
new SqlParameter("@ziwojieshao",SqlDbType.VarChar,100),
};
pa[0].Value = "liming";
pa[1].Value =" 123456";