简单一段代码,怎么插入数据库两次了?

Aimar168 Aimar168 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
if(Page.IsValid)
{
string username = txtUsername.Text;
string password = FormsAuthentication.HashPasswordForStoringInConfigFile (txtPassword.Text,"md5");
string email = txtEmail.Text;
string connString = "server=(local);database=guestbook;uid=sa;pwd=321560;";
SqlConnection conn = new SqlConnection(connString);
string sql = "INSERT INTO users(username,password,email) values('"+username+"','"+password+"','"+email+"')"; //怎么同时插入一模一样的纪录?
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.ExecuteNonQuery();
conn.Close();
Response.Write("<script language='javascript'>{alert('注册成功!');window.location.href='default.aspx'}</script>");
}
...全文
评论 14
收藏 已收藏
分享
返回顶部
Aimar168
.NET社区 62,272 成员 668,968 内容