Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 syntax error in string in query expression '45')

Author  Topic 

bndck
Starting Member

7 Posts

Posted - 2011-01-20 : 01:30:41
Hi,,

This is my statement which gives me error as "syntax error in string in query expression '45')"

Con.Execute "INSERT INTO Sold_Products_Temp(Date_sold,Product_Code,Description,Sold_rolls,Sold_mts,Category) VALUES (#" & DTPicker1.Value & "#,'" & Text1(0).Text & "','" & Text1(1).Text & "'," & toNumber(Text1(5).Text) & "," & toNumber(Text1(6).Text & " ,'" & Text1(4).Text) & "')"

can anyone suggest sollution plz.

many thanks

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-01-20 : 04:27:49
#" & DTPicker1.Value & "# should be '" & DTPicker1.Value & "' is all I can see.
Go to Top of Page

bndck
Starting Member

7 Posts

Posted - 2011-01-20 : 04:51:23
quote:
Originally posted by RickD

#" & DTPicker1.Value & "# should be '" & DTPicker1.Value & "' is all I can see.



Thanks RickD,

I tried

same error with "345" error code

syntax error in string in query expression '45')..

many thanks
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-01-20 : 06:57:56
Do like this instead:

SQL = "INSERT INTO Sold_Products_Temp(Date_sold,Product_Code,Description,Sold_rolls,Sold_mts,Category) VALUES (#" & DTPicker1.Value & "#,'" & Text1(0).Text & "','" & Text1(1).Text & "'," & toNumber(Text1(5).Text) & "," & toNumber(Text1(6).Text & " ,'" & Text1(4).Text) & "')"
Response.Write(SQL)
Response.End
Con.Execute(SQL)


- Lumbago

My blog-> www.thefirstsql.com
Go to Top of Page

bndck
Starting Member

7 Posts

Posted - 2011-01-20 : 07:56:30
Hi Lumbago

thanks for your reply,.

still error..

many thanks
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-20 : 08:50:06
Have you looked at the string that is created?


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -