- C# code
protected void Button1_Click(object sender, EventArgs e) { //access链接字符串 string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + Server.MapPath("~\\DataBase\\#wulong.mdb"); //生成一个新的连接 string sql = "Insert Into users (UserName,Password,Lm)values('" + UserName.Text.ToString() + "','" + Password.Text.ToString() + "','" + Lm.SelectedValue.ToString() + "')"; //Response.Write(sql); //Response.End(); OleDbConnection myConn = new OleDbConnection(strConn); OleDbCommand InsCommand = new OleDbCommand(sql, myConn); myConn.Open(); InsCommand.ExecuteNonQuery(); myConn.Close(); Response.Write("<script> alert('用户资料添加成功!');window.location.href='UserEdit.aspx';</script>"); }
sql语句放到access里测试没问题,大侠们看看
------解决方案--------------------------------------------------------
放到SQL SERVER里就有问题了?是吗?
------解决方案--------------------------------------------------------
using system sqlclient;
sqlconnection sqlcmmand
------解决方案--------------------------------------------------------
没有出错信息吗?