当前位置: 代码迷 >> ASP.NET >> insert into 插入失败?解决方法
  详细解决方案

insert into 插入失败?解决方法

热度:3719   发布时间:2013-02-25 00:00:00.0
insert into 插入失败?
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
------解决方案--------------------------------------------------------
没有出错信息吗?
  相关解决方案