如何解决数据库中的此错误 [英] How to solve this error in database

查看:127
本文介绍了如何解决数据库中的此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


这篇关于如何解决数据库中的此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆