UPDATE syntax error

workmad3

***** Slob
Local time
Today, 23:01
Joined
Jul 15, 2005
Messages
375
Im having trouble getting an SQL update to work. It keeps on saying 'Syntax error in UPDATE statement'. I cant seem to see anything wrong with my code, so i think i need someone else to see it. heres the code thats not working

Code:
        conn.BeginTrans
        Dim Sql As String
        Sql = "UPDATE Quotes SET Date = '" & txtDate.Value & "' " & _
                ", QuoteType = " & opgQuoteType.Value
        If Not IsNull(txtDescription.Value) Then
            Sql = Sql & ", Description = '" & _
                txtDescription.Value & "' "
        Else
            Sql = Sql & ", Description = ' ' "
        End If
        Sql = Sql & " WHERE QuoteID = " & QuoteID & ";"
                
        MsgBox Sql
        conn.Execute Sql
        conn.CommitTrans

any help would be appreciated. I cant get any more done on this until i have this problem solved.
 
Mad,

Assuming that Date is really a DateTime field (and knowing that Date
is a reserved word):

Code:
Sql = "UPDATE Quotes SET Date = #" & txtDate.Value & "# " & _
                ", QuoteType = " & opgQuoteType.Value

Change Date to something else.

Wayne
 
i had already tried that, and when it didnt work, changed the date field to a text field rather than date/time, so thats not it :(
 
oops, should have read the message better... the # thing id already tried, but changing date worked, so all good now.
 
ok, now for another question along the same lines.

is it possible to save a newline using sql (i have some multi line text boxes and i would like to save them with the newline characters if possible)
 
ignore the above post. the problem was with a completely different part of the syntax. It does exactly what i want anyway :)
 

Users who are viewing this thread

Back
Top Bottom