请教asp.net插入数据库的问题

[复制链接]
查看11 | 回复1 | 2008-11-9 21:04:01 | 显示全部楼层 |阅读模式
protected void btnNext2_Click(object sender, EventArgs e)

{

try

{

SqlConnection con = MyDB.creatConnection();

con.Open();

string sql = "insert into login (userName,userPwd) values('" + pid.Text + " '" + pwd.Text + "'')";

SqlCommand cmd = new SqlCommand("sql, con");

cmd.ExecuteNonQuery();

con.Close();

}

catch

{

Response.Write("插入失败!");

}


}
请问以上代码有问题吗?为什么总显示插入失败?

回复

使用道具 举报

千问 | 2008-11-9 21:04:01 | 显示全部楼层
string sql = "insert into login (userName,userPwd) values('" + pid.Text + "','" + pwd.Text + "')"; SqlCommand cmd = new SqlCommand(sql, con); --------------------------------------------- 落叶枫晨小说网http://www.joytxt.com/,打造免费小说新纪元...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行