高手帮我看看我这哪里错了。(用户代码未处理 OleDbException 文件名无效。)
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.We...
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Web.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String ConStr = WebConfigurationManager.ConnectionStrings["accessCon"].ToString();
OleDbConnection conn = new OleDbConnection(ConStr);
conn.Open();
string InsertStr = "INSERT INTO userTable(userName,userPwd,Sex,tel,email,carrer,introducation) VALUES('王五','123','男','571-59655555','ww@sohu.com','学生','品学兼优')";
OleDbCommand cmd = new OleDbCommand(InsertStr, conn);
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT*FROM userTable OREDR BY userId";
OleDbDataReader dr = cmd.ExecuteReader();
GridView gv = new GridView();
gv.DataSource = dr;
gv.DataBind();
form1.Controls.Add(gv);
conn.Close();
Response.Write("用户添加成功!");
}
}
这是代码。。目的是利用INSERT语句,向ACCESS数据库中添加用户 展开
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Web.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String ConStr = WebConfigurationManager.ConnectionStrings["accessCon"].ToString();
OleDbConnection conn = new OleDbConnection(ConStr);
conn.Open();
string InsertStr = "INSERT INTO userTable(userName,userPwd,Sex,tel,email,carrer,introducation) VALUES('王五','123','男','571-59655555','ww@sohu.com','学生','品学兼优')";
OleDbCommand cmd = new OleDbCommand(InsertStr, conn);
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT*FROM userTable OREDR BY userId";
OleDbDataReader dr = cmd.ExecuteReader();
GridView gv = new GridView();
gv.DataSource = dr;
gv.DataBind();
form1.Controls.Add(gv);
conn.Close();
Response.Write("用户添加成功!");
}
}
这是代码。。目的是利用INSERT语句,向ACCESS数据库中添加用户 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询