insert sql statement fails

Directlinq

Registered User.
Local time
Today, 13:36
Joined
Sep 13, 2009
Messages
67
Hi can somebody please help me find out why this code will not insert the data into the table.
I have spent about 8 hours trying to find out why it wont work.

Code:
CurrentDb.Execute "INSERT INTO dbo_tblArtist (artist_id,artist_name,artist_description,image_filename) " & "VALUES ('" & aid & "','" & artist & "','',''); "
Please help

aid is a string that is a number
and artist is a text name

Many Thanks
 
Values for numeric data types should not be surrounded by single quotes.
 
if aid is a number, try entering it without it's own quotation marks. i.e., change
Code:
[COLOR=Red]'[/COLOR]" & aid & "[COLOR=Red]'[/COLOR]
to
Code:
'" & aid & "

see if that helps...

also, i presume (as access would) that "aid" in your SQL is actually a field in your form? in which case it may be better to write something like Me.aid (or even better, if you had used more stringent rules in naming your fields, it might be something like Me.txtAid)
 
Hi
Now im getting this error after the change you suggested

Code:
syntax error (mising opperator) in query expression "1225 , 'Armand van heldon + ducksauce','','');"

Many Thanks
 
What is your code now? wiklendt inadvertently left in the leading single quote, which should not be in there.
 
What is your code now? wiklendt inadvertently left in the leading single quote, which should not be in there.
oops... yes, that was inadvertant.

Directlinq, are you trying to insert from a multi-select listbox? (if not a listbox, then how?) i.e., is "Armand van heldon + duck sauce" an artist name, or is there something else going on there? i.e., what is "duck sauce" in this context?
 

Users who are viewing this thread

Back
Top Bottom