简体   繁体   English

在db2数据库上插入失败(在iSeries上)

[英]Insert fails on db2 database (on iSeries)

We are having trouble inserting records into a file/table on an iSeries from our VB.NET 2010 application. 我们无法从VB.NET 2010应用程序将记录插入到iSeries上的文件/表中。

The old system running on Windows Xp has no problems but we are trying to run the code (insode VS 2010) on a Windows 7 64-bit box, and OS400 V5.4 在Windows Xp上运行的旧系统没有问题,但是我们尝试在Windows 7 64位盒和OS400 V5.4上运行代码(insode VS 2010)

Here is the error message returned by the driver: 这是驱动程序返回的错误消息:

ERROR [42000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0104 - Token 2014 was not valid. Valid tokens: ) ,.

Here are the relevant parts of the code: 以下是代码的相关部分:

sConStr = "Driver={Client Access ODBC Driver (32-bit)};" & _
    "System=" & sAS400Server & ";" & _
    "Uid=" & UCase(sAS400UserName) & ";" & _
    "Pwd=" & UCase(sAS400UserPwd) & ";" & _
    "DBQ=" & UCase$(sAS400Library) & _
    IIf(Trim$(sLibraryOther) <> "", "," & sLibraryOther, "") & _
        ";COMPRESSION=1;ALLOWUNSCHAR=1;TRANSLATE=1;"

conOdbc = New Odbc.OdbcConnection(sConStr)
conOdbc.Open()

We create out INSERT statement which looks like this: 我们创建出INSERT语句,如下所示:

"INSERT INTO kerry.YSEPF(YSESID, YSESAN, YSESCC, YSECCY, YSENEGP, YSEAMA, YSESPOD, YSEVFR, YSESNAR, YSELMBY, YSELMPC, YSECRBY, YSECRPC) VALUES (0002109416, 12345678, PS , GBP, C, 000000000006851, 1140918, 1140831, August 2014 Fuel for Co.van                                 , N , 'profile  ','DPVO           ','profile  ','DPVO           ')"

Then we try to insert as below: 然后我们尝试如下插入:

iSubmitItems += 1
Try
    iRetVal = cmdOdbc.ExecuteNonQuery()
        iSubmitItemsSuccess += 1
 Catch ex As Exception
     iSubmitItemsFail += 1

and every time we get the error message. 并且每次我们收到错误消息。

Is there something we are missing such as the driver (is it a 32-bit driver but installed in a different place on Win64?) 是否缺少诸如驱动程序之类的东西(是否是32位驱动程序,但安装在Win64上的其他位置?)

EDIT Just wanted to mention that also, the target files is packed or compressed, this is why we can't FTP the data in fixed length text format, whish is what we do for some other data imports 编辑只是想提一下,目标文件是打包或压缩的,这就是为什么我们不能以固定长度的文本格式FTP数据的原因,这是我们对其他一些数据导入所做的工作

Thanks for any help 谢谢你的帮助

Your SQL is invalid: 您的SQL无效:

[..snip...]6851, 1140918, 1140831, August 2014 Fuel for Co.van   [...snip...]
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

Strings must be encapsulated in quotes, eg 字符串必须用引号引起来,例如

[..snip...]6851, 1140918, 1140831, 'August 2014 Fuel for Co.van'   [...snip...]
                                   ^---------------------------^---

And given this trivial/beginner error, I'm going to say that you're also vulnerable to SQL injection attacks . 考虑到这个琐碎/初学者的错误,我要说的是,您也容易受到SQL注入攻击的攻击

The problem is with your INSERT statement. 问题出在您的INSERT语句上。 You are missing quotes around some of the values. 您缺少某些值的引号。 I am not sure of the data types of your columns, so I am going to assume they are all varchar. 我不确定您的列的数据类型,因此我将假定它们都是varchar。

This: 这个:

"INSERT INTO kerry.YSEPF(YSESID, YSESAN, YSESCC, YSECCY, YSENEGP, YSEAMA, YSESPOD, YSEVFR, YSESNAR, YSELMBY, YSELMPC, YSECRBY, YSECRPC) VALUES (0002109416, 12345678, PS , GBP, C, 000000000006851, 1140918, 1140831, August 2014 Fuel for Co.van                                 , N , 'profile  ','DPVO           ','profile  ','DPVO           ')"

Should be something like this: 应该是这样的:

"INSERT INTO kerry.YSEPF(YSESID, YSESAN, YSESCC, YSECCY, YSENEGP, YSEAMA, YSESPOD, YSEVFR, YSESNAR, YSELMBY, YSELMPC, YSECRBY, YSECRPC) VALUES ('0002109416', '12345678', 'PS' , 'GBP', 'C', '000000000006851', '1140918', '1140831', 'August 2014 Fuel for Co.van', 'N' , 'profile','DPVO','profile','DPVO')"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM