SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Run-time error 3709

Last post 07-11-2008, 11:37 by horatio. 4 replies.
Sort Posts: Previous Next
  •  07-11-2008, 8:42 13280

    Storm [st] Run-time error 3709

    Hi All,

    I am a newby so please understand if I ask a stupid question.....

    I get an "Synatx Error in update statement" error.

    In my Global.bas Module I have the following:
    Public cn As New ADODB.Connection
    Public rs As New ADODB.Recordset
    Public dBase As String

    In my Main.form I have:
    Private Sub MDIForm_Load()
    dBase = App.Path & "\Inventory.mdb"
    cn.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" & dBase
    mnuLeads.Enabled = False
    mnuReps.Enabled = False
    mnuDbase.Enabled = False
    End Sub

    The statement that I have a problem with is:
    rs.Open "Update tblLead set Client Name='" & Sup_CName & "',Client Surname='" & Sup_Surname & "',Client Address='" & sAddr & "',Client Cell='" & sTele & "',App Date='" & sDate & "',Satus='" & sStatus & "',Rep='" & sRep & "'" & _
    "Where Lead_ID='" & iFind & "'", cn, 3, 3

    Now I admit that this code is not mine but was found on another site. I just cant seem to get it to work.

    Will someone please help???


    Thanks


    Swannie

    PS. I can make the project available for download if nescesarry.
  •  07-11-2008, 8:50 13281 in reply to 13280

    Re: Run-time error 3709

    First things first. Google SQL Injection and read a few articles. It's not specific to SQL Server

    First guess, you have field names with a space in them. Access required that those get wrapped in []  (I think. It's been a while since i played with access). So your update becomes

    rs.Open "Update tblLead set [Client Name] ='" & ...

    If that doesn't work, build up the update to a string variable and print it to the debug window so that you can examine it.


    Gail Shaw - SQL In the Wild
    SQL Server MVP
    --
    Chaos, panic and disorder. My job here is done!
  •  07-11-2008, 8:52 13282 in reply to 13280

    Re: Run-time error 3709

    Swannie1971:
    The statement that I have a problem with is:
    rs.Open "Update tblLead set Client Name='" & Sup_CName & "',Client Surname='" & Sup_Surname & "',Client Address='" & sAddr & "',Client Cell='" & sTele & "',App Date='" & sDate & "',Satus='" & sStatus & "',Rep='" & sRep & "'" & _
    "Where Lead_ID='" & iFind & "'", cn, 3, 3

    And also, is your "rs" object a recordset object? If it is just so you know you don't need to use a recordset to do an update, use your connection instead:

    cn.Execute "update..."

    Or something like that... haven't used VB in a while so it might be cn.Exec...



    "I would love to change the world, but they won't give me the source code"
    SMS your TO DO list to your email
  •  07-11-2008, 10:35 13288 in reply to 13280

    Re: Run-time error 3709

    Swannie, here's a nice ADO tutorial, which covers most aspects of ADO :)

    http://www.timesheetsmts.com/adotutorial.htm

    Just a personal comment, IMHO, it's not good to have spaces in table field names.  It causes too much issues, especially with Access as GilaMosnter ponted out.

    If you look at the meaning of this error, it could mean either that a specified field could refer to more than one table listed in the FROM clause of your SQL statement; or, that it is an ambigious field reference.  I don't know if that would perhaps nudge you in the right direction.

    I hope my comments were useful :)


    It's Not Answers That Change The World, It's Questions
  •  07-11-2008, 11:37 13295 in reply to 13280

    Re: Run-time error 3709

    Swannie1971:


    The statement that I have a problem with is:
    rs.Open "Update tblLead set Client Name='" & Sup_CName & "',Client Surname='" & Sup_Surname & "',Client Address='" & sAddr & "',Client Cell='" & sTele & "',App Date='" & sDate & "',Satus='" & sStatus & "',Rep='" & sRep & "'" & _
    "Where Lead_ID='" & iFind & "'", cn, 3, 3

     
    Hi Swannie,
     
    I see you update a field called "satus" with a variable named "sStatus". Are you sure the spelling is correct? Also, are one of the fields you are updating a memo field? Perhaps the value you are updating it with is too large for the memo field to handle?
    Try googling that specifc runtime error number and see if you get anything that helps you.
     
    Ciao,

    The Question is the Answer, and the Answer is the Question!
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems