如何解决数据库中的此错误

编程入门 行业动态 更新时间:2024-10-20 21:12:38
本文介绍了如何解决数据库中的此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

ssql =插入store_master(vono,trndate,invoiceno,invoicedate,supcode,description,gross,discount,net,taxt_rate,total_amont,discountafter,fright,payable,naration,site)的值"& _ ("& Me.txt_grn.Text&","& DateTime.Today().ToString(" MM/dd/yyyy)&"'',''&格式(Me.dtp_srv.Value,"MM/dd/yyyy")&'',"& _ "& Me.txt_invoiceno.Text& ","& DateTime.Today().ToString("MM/dd/yyyy")& ","&格式(Me.dtp_invoicedate.Value,"MM/dd/yyyy")& ",& _ "& Me.txt_supcod.Text& ","& Me.cmbsupp.Text& ",& _ "& Me.txt_gross.Text& ",& _ "& Me.txt_discount.Text& ","& Me.txt_net.Text& ",& _ "& Me.cmbtax.Text& ",& _ "& Me.txt_Tamont.Text& ",& _ "& Me.txt_afterdsc.Text& ",& _ "& Me.txt_freight.Text& ",& _ "& Me.txt_pyable.Text& ",& _ "& Me.txt_naration.Text& ","&登录网站和")" fn.saveqry(ssql,tblname) tblname = String.Empty ssql = String.Empty tblname ="store_child" 对于tcnt = 1 To .Rows.Count-1 如果Convert.ToString(.GetData(tcnt,"itmcode"))="或Convert.ToString(.GetData(tcnt,"iname"))="然后 致电txtclear() hcode = String.Empty 呼叫maxno() 退出子 如果结束 ssql =插入store_child(vono,site,itmcode,iqty,irate,total,remark)值"& _ ("& Me.txt_grn.Text&","&登录站点&"'',& _ "& Replace(CStr(.GetData(tcnt,"itmcode"))),-",")& ",& _ "& CStr(.GetData(tcnt,"iqty"))& ",& _ "& CStr(.GetData(tcnt,"irate"))& ",& _ "& CStr(.GetData(tcnt,"itotal"))& ",& _ "& CStr(.GetData(tcnt,"remark"))& "" 这是我的插入语句以及我的数据表列, 但是当我执行这段代码时 它显示此错误 insert语句中的列数少于values子句中指定的值,列数必须与insert语句中指定的列数相匹配... 我签出了它,但values子句和插入语句中的列相同,请帮助我..............

ssql = "insert into store_master(vono,trndate,invoiceno,invoicedate,supcode,description,gross,discount,net,taxt_rate,total_amont,discountafter,fright,payable,naration,site) values" & _ "(''" & Me.txt_grn.Text & "'',''" & DateTime.Today().ToString("MM/dd/yyyy") & "'',''" & Format(Me.dtp_srv.Value, "MM/dd/yyyy") & "''," & _ "''" & Me.txt_invoiceno.Text & "'',''" & DateTime.Today().ToString("MM/dd/yyyy") & "'',''" & Format(Me.dtp_invoicedate.Value, "MM/dd/yyyy") & "''," & _ "''" & Me.txt_supcod.Text & "'',''" & Me.cmbsupp.Text & "''," & _ "''" & Me.txt_gross.Text & "''," & _ "''" & Me.txt_discount.Text & "'',''" & Me.txt_net.Text & "''," & _ "''" & Me.cmbtax.Text & "''," & _ "''" & Me.txt_Tamont.Text & "''," & _ "''" & Me.txt_afterdsc.Text & "''," & _ "''" & Me.txt_freight.Text & "''," & _ "''" & Me.txt_pyable.Text & "''," & _ "''" & Me.txt_naration.Text & "'',''" & loginsite & "'')" fn.saveqry(ssql, tblname) tblname = String.Empty ssql = String.Empty tblname = "store_child" For tcnt = 1 To .Rows.Count - 1 If Convert.ToString(.GetData(tcnt, "itmcode")) = "" Or Convert.ToString(.GetData(tcnt, "iname")) = "" Then Call txtclear() hcode = String.Empty Call maxno() Exit Sub End If ssql = "insert into store_child(vono,site,itmcode,iqty,irate,itotal,remark) values" & _ "(''" & Me.txt_grn.Text & "'',''" & loginsite & "''," & _ "''" & Replace(CStr(.GetData(tcnt, "itmcode")), "-", "") & "''," & _ "''" & CStr(.GetData(tcnt, "iqty")) & "''," & _ "''" & CStr(.GetData(tcnt, "irate")) & "''," & _ "''" & CStr(.GetData(tcnt, "itotal")) & "''," & _ "''" & CStr(.GetData(tcnt, "remark")) & "''" this is my insert statement with my data table coloumns, but when i execute this code it show this error there are fewer column in the insert statement then values specified in the values clause,the number of columns must match the number of columns specified in insert statements... i checked out it but columns in values clause and in insert statements are the same,plz help me out..............

推荐答案

ssql = "insert into store_master(vono,trndate,invoiceno,invoicedate,supcode,description,gross, discount,net,taxt_rate,total_amont,discountafter,fright,payable,naration,site) values" & _ "('" & Me.txt_grn.Text & "','" & DateTime.Today().ToString("MM/dd/yyyy") & "','" & Format(Me.dtp_srv.Value, "MM/dd/yyyy") & "'," & _ "'" & Me.txt_invoiceno.Text & "','" & DateTime.Today().ToString("MM/dd/yyyy") & "','" & Format(Me.dtp_invoicedate.Value, "MM/dd/yyyy") & "'," & _ "'" & Me.txt_supcod.Text & "','" & Me.cmbsupp.Text & "'," & _ "'" & Me.txt_gross.Text & "'," & _ "'" & Me.txt_discount.Text & "','" & Me.txt_net.Text & "'," & _ "'" & Me.cmbtax.Text & "'," & _ "'" & Me.txt_Tamont.Text & "'," & _ "'" & Me.txt_afterdsc.Text & "'," & _ "'" & Me.txt_freight.Text & "'," & _ "'" & Me.txt_pyable.Text & "'," & _ "'" & Me.txt_naration.Text & "','" & loginsite & "')"

You have 16 columns mentioned whereas 18 values have been provided in the insert SQL.

您说已验证变量完全匹配 那么在一种情况下可能会有问题 如果您提供的数据包含单引号或逗号,则需要处理这些.. 调试它得到查询并直接在数据库中执行..u会尝试它 you said that verified the variables exactly matched then there may be problem in one situation if the data supplied by you contains single quote or comma you need to handle those .. debug it get the query and execute it in database directly..u will get it try it

更多推荐

如何解决数据库中的此错误

本文发布于:2023-10-30 04:24:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541756.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何解决   数据库中   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!