点击添加按钮事件的时候也出现了这个问题,很简单的一段代码应该没问题的哦!
而且id是自动增长的,应该用不着吧?
代码 Models.clientorder model = new Models.clientorder();
model.Projname = this.txtprojname.Text;
model.Clientname = this.txtclientname.Text;
model.Orderdate = Convert.ToDateTime(this.txtorderdate.Text);
model.Telphone = Convert.ToInt32(this.txttelphone.Text);
model.Email = this.txtemail.Text;
model.Finishdate = Convert.ToDateTime(this.txtfinishdate.Text); OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("App_Data/ClientManage.mdb"));
conn.Open();
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values (" + txtprojname.Text + "," + txtclientname.Text + "," + txtorderdate.Text + "," + txttelphone.Text + "," + txtemail.Text + "," + txtfinishdate.Text + ")";
OleDbCommand cmd = new OleDbCommand(strSql, conn);
cmd.ExecuteNonQuery();
clientorder.Add(model);
conn.Close();
Response.Write("成功!");
大家帮忙看下,有什么遗漏的,access用的不熟!
而且id是自动增长的,应该用不着吧?
代码 Models.clientorder model = new Models.clientorder();
model.Projname = this.txtprojname.Text;
model.Clientname = this.txtclientname.Text;
model.Orderdate = Convert.ToDateTime(this.txtorderdate.Text);
model.Telphone = Convert.ToInt32(this.txttelphone.Text);
model.Email = this.txtemail.Text;
model.Finishdate = Convert.ToDateTime(this.txtfinishdate.Text); OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("App_Data/ClientManage.mdb"));
conn.Open();
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values (" + txtprojname.Text + "," + txtclientname.Text + "," + txtorderdate.Text + "," + txttelphone.Text + "," + txtemail.Text + "," + txtfinishdate.Text + ")";
OleDbCommand cmd = new OleDbCommand(strSql, conn);
cmd.ExecuteNonQuery();
clientorder.Add(model);
conn.Close();
Response.Write("成功!");
大家帮忙看下,有什么遗漏的,access用的不熟!
解决方案 »
- int成员变量的困惑
- 请问如何让div的display状态在postback后还能够保持?
- 日历日记
- System.Int32怎么强制转换成System.String
- Visual Studio 2005 Web Application Projects支持中文版的发布了吗????
- 正则表达式问题
- response.redirect()参数问题
- 当进行删除操作时出错了,请帮帮忙吧谢谢。
- 一般更新数据的时候,是直接用SQL语句,还是DATASET再返回数据源?
- 请问个巨菜的问题,,我如何更改VS.net代码编辑的字体
- 跪求!asp.net这种的空值该怎样判断!!!aa{}
- C#如何在窗体中动态创建N个按钮
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" + txtorderdate.Text + "','" + txttelphone.Text + "','" + txtemail.Text + "','" + txtfinishdate.Text + "')";
'" + 值 + "'
加断点看看哪个对象为null
报错在哪说下先
同头疼 用sqlparameter吧或者formate下都清楚点