Solved

Writing to AS400 compatability problem

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now