CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Visual basic and sql

    I have a vb script that is triggered by an event sink.

    My problem is with a sql insert statement.

    The script basically strips out an incoming email, reforms it and forwards it on - within the script however im trying to insert the stripped out values into a sql database.

    This works fine with certain values im trying to insert however one of the strings im trying to insert is a url i.e http://xxx.xxxcom/xxxx.asp?Id=e1a9e5...0-339faf481c25

    The insert fails when this is added as a variable ie

    links = "http://xxx.xxxcom/xxxx.asp?Id=e1a9e5da-9929-4616-bb40-339faf481c25"

    SQL_Insert = "Insert into MyTable (id, AOI,Inc,Link)" & _
    "values (" & id & ",'" & aoistring & "','" & inc & "','" & links & "')"
    Set dbRS= cn.Execute(SQL_Insert)

    But if it added directly as a string in the insert it is successful ie
    SQL_Insert = "Insert into MyTable (id, AOI,Inc,Link)" & _
    "values (" & id & ",'" & aoistring & "','" & inc & "','http://xxx.xxxcom/xxxx.asp?Id=e1a9e5da-9929-4616-bb40-339faf481c25')"
    Set dbRS= cn.Execute(SQL_Insert)

    Can anyone shed any light on this as I am baffled.

    The same code works fine using asp and vbscript with variables.

    Thanks

    Tim
    Reply With Quote

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    106

    Re: Visual basic and sql

    Do you see any differences in the immediate window if you ask the value of SQL_Insert ?

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Visual basic and sql

    Try to debug.print your SQL_insert string and check if it results in exactly the same as you entered manually.

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Visual basic and sql

    Might also help if you told us what the error is that you are receiving

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured