Solved

Writing to AS400 compatability problem

Posted on 2004-04-06
3
903 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent checkbox click event occur while editing it in vb6 8 56
How to Add / Edit Windows Menu 4 67
Help me. 3 60
Formula problem with Excel attachment 6 38
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

808 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