Insert data to DB2 database using VB and SQL stored procedure

48175 pts.
Tags:
AS/400
IBM iSeries
Microsoft SQL Server 2000
SQL
VB.NET
I have spent a few days trying to find a solution using Google. Has anyone had luck with this problem? Simply put we are trying to send data from our web service to our I-Series. We need to do this via a SQL stored procedure. When we do the insert dynamically it works as long as there are no single quotes in the data. If someone has a name like Dave's Plumbing it blows up. We can do a replace of the char like this. dr("SoldToCompany") = dr("SoldToCompany").replace(Chr(39), " ") But the data is not "really" correct. The name is now Dave s Plumbing. Is there a way to keep the single quote doing it dynamically? Or has anyone found a better method? Any suggestions would be great.

Software/Hardware used:
sql server 2000, i-series

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • philpl1jb

    Try sending two single quotes instead of one.

    The 400 sees a single quote as ending a string .. but two single quotes as a literal single quote.

    53,890 pointsBadges:
    report
  • ToddN2000

    Tried your suggestion replacing with 2 single quotes, it worked!! Thanks.

    dr("SoldToCompany") = dr("SoldToCompany").replace(Chr(39), "''").

    48,175 pointsBadges:
    report
  • carlosdl
    Yep, one single quote works as a escape character for the other one.
    77,155 pointsBadges:
    report
  • philpl1jb

    Thanks for responding Todd.

    "I had intended to have gone into Africa incognito. But the fact that a white man, even an American, was about to enter Africa was soon known all over Zanzibar."

    Henry Morton Stanley


     

    53,890 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: