至少一个参数没有被指定值。

IT0329 2011-04-25 10:54:53
点击添加按钮事件的时候也出现了这个问题,很简单的一段代码应该没问题的哦!
而且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用的不熟!
...全文
267 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
IT0329 2011-04-27
  • 打赏
  • 举报
回复
不好意思各位,结账有点晚了!
  • 打赏
  • 举报
回复
断点得到真实sql,然后放到查询分析中执行调试
子夜__ 2011-04-25
  • 打赏
  • 举报
回复


'" + txtprojname.Text + "'
'" + 值 + "'
inso2010 2011-04-25
  • 打赏
  • 举报
回复
哇,1楼好快啊,呵呵
inso2010 2011-04-25
  • 打赏
  • 举报
回复
是字符串参数的要加上引号

string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" + txtorderdate.Text + "','" + txttelphone.Text + "','" + txtemail.Text + "','" + txtfinishdate.Text + "')";
gw6328 2011-04-25
  • 打赏
  • 举报
回复
就是,没有引号
我姓区不姓区 2011-04-25
  • 打赏
  • 举报
回复
缺了单引号了吧
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" + txtorderdate.Text + "','" + txttelphone.Text + "','" + txtemail.Text + "','" + txtfinishdate.Text + "')";
alan_219_2008 2011-04-25
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 fengyarongaa 的回复:]

引用 1 楼 ojlovecd 的回复:

缺了单引号了吧
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" ……
[/Quote]

同头疼 用sqlparameter吧

或者formate下都清楚点
ycproc 2011-04-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ojlovecd 的回复:]

缺了单引号了吧
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" + txtorderdate.Text + "'……
[/Quote]

看到这个东西 头疼

han578178367 2011-04-25
  • 打赏
  • 举报
回复
插入的数据类型如果是varchar()字符串要加单引号的
SeanDing1989 2011-04-25
  • 打赏
  • 举报
回复
缺少单引号
mayanly 2011-04-25
  • 打赏
  • 举报
回复
报错在哪?貌似问题就解决了
阳明 to life 2011-04-25
  • 打赏
  • 举报
回复
clientorder.Add(model);这句话干嘛的 静态方法?参数是自身的一个对象?
报错在哪说下先
xrongzhen 2011-04-25
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 it0329 的回复:]
引用 1 楼 ojlovecd 的回复:
缺了单引号了吧
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" + t……
[/Quote]

哪个地方报的错? 报错了,功能还能实现?
我姓区不姓区 2011-04-25
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 it0329 的回复:]

功能是可以了,但是调试的时候提示了未将对象引用到对象实例,一并帮我搞定吧?
[/Quote]

加断点看看哪个对象为null
IT0329 2011-04-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ojlovecd 的回复:]
缺了单引号了吧
string strSql = "insert into clientorder (projname,clientname,orderdate,telphone,email,finishdate) values ('" + txtprojname.Text + "','" + txtclientname.Text + "','" + txtorderdate.Text + "',……
[/Quote]

功能是可以了,但是调试的时候提示了未将对象引用到对象实例,一并帮我搞定吧?

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧