Solved

Writing to AS400 compatability problem

Posted on 2004-04-06
3
886 Views
Last Modified: 2013-12-25
I am trying to insert a record to a table in AS400 from VB 6.0 program. I am reading the data from a table on SQL server. It works fine with the following code

      strAS400 = ReadINI(gtINIFile, AS400, "ConnectString", "")
      cnAS400.Open strAS400
   
      Do While Not rsShip.EOF
         With rsShip.Fields
            strSQL = "INSERT INTO FUTBARPRNT.RSPBPHST " & _
                          "(COMPNY, SERIAL#, CABBV, CPART, PARTNO, DABBV, LBLFMT, PCNAME, PRNTER, BARPT#) " & _
                   "VALUES " & _
                   "('" & .Item("fdCompany").Value & "', '" & _
                          .Item("fdSerialNumber").Value & "', '" & _
                          .Item("fdCustDestination").Value & "', '" & _
                          .Item("fdCustPartNumber").Value & "', '" & _
                          .Item("fdShortNumber").Value & "', '" & _
                          .Item("fdDestination").Value & "', '" & _
                          .Item("fdLabelFormat").Value & "', '" & _
                          .Item("fdIPAddress").Value & "', '" & _
                          .Item("fdPrinter").Value & "', '" & _
                          .Item("fdBarPartNumber").Value & "')”

But when I add another field  called QTY it gives the following error.
Error Number: -2147467259
Error Description: [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0408 - VALUE FOR COLUMN OR VARIABLE QTY NOT COMPATIBLE.

Here is the code after adding the QTY field.


      strAS400 = ReadINI(gtINIFile, AS400, "ConnectString", "")
            cnAS400.Open strAS400
   
                Do While Not rsShip.EOF
                     With rsShip.Fields

                      strSQL = "INSERT INTO FUTBARPRNT.RSPBPHST " & _
                                    "(COMPNY, SERIAL#, CABBV, CPART, PARTNO, DABBV, LBLFMT, PCNAME, PRNTER, BARPT#, QTY " & _
                       "VALUES " & _
                       "('" & .Item("fdCompany").Value & "', '" & _
                          .Item("fdSerialNumber").Value & "', '" & _
                          .Item("fdCustDestination").Value & "', '" & _
                          .Item("fdCustPartNumber").Value & "', '" & _
                          .Item("fdShortNumber").Value & "', '" & _
                          .Item("fdDestination").Value & "', '" & _
                          .Item("fdLabelFormat").Value & "', '" & _
                          .Item("fdIPAddress").Value & "', '" & _
                          .Item("fdPrinter").Value & "', '" & _
                          .Item("fdBarPartNumber").Value & "', '" & _
                          .Item("fdQuantity").Value & "')"

The field fdQuantity on the SQL Server is numeric(5). On the AS400 side the field QTY is decimal(8). Does anybody know how to fix this error? One thing I thought about is using the CAST function. But I don’t know the syntax of the CAST function on this particular program.

0
Comment
Question by:shamif
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 150 total points
ID: 10767370
Since this is not a char field in AS400 you do not need to put it in single quotes.  Try:

                      .Item("fdBarPartNumber").Value & "', " & _
                      .Item("fdQuantity").Value & ")"

Leon
0
 

Author Comment

by:shamif
ID: 10767691
thanks leonstryker,

It worked. I feel so stupid.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 10767709
No problem.  We all been there.

Leon
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question