读书人

insert into 插入失败?解决方法

发布时间: 2012-04-05 12:42:40 作者: rapoo

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
[解决办法]
没有出错信息吗?

读书人网 >asp.net

热点推荐