Solved

Writing to AS400 compatability problem

Posted on 2004-04-06
3
914 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 41
Visual Studio 2005 text editor 10 48
Export Data to Different .csv Files 26 121
Macro problems with Excel file 6 22
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

735 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