invalid sql statement,expected "delete","insert","procedure","select" or "update"
it a run time error which i recieve when an saving a record to the database. and this is the code.
rsord.Open "order", cnnord, adOpenKeyset, adLockPessimistic
cnnord.Execute "INSERT INTO order(OrderId,DateOrdered,CustomerId,QuatityOrdered,ProductTitle,PurchasedUnitPrice);" _
& "VALUES('" & txtoid.Text & "','" & txtod.Text & "','" & txtcid.Text & "',' " & txtqo.Text & "',' " & txtPt.Text & "',' " & txtpup.Text & "');"


the bolded statement is highlitened yellow when the error occurs
thanks dani

Recommended Answers

All 2 Replies

use anyone of the followings :-

if rsord.state=adstateopen then rsord.close
rsord.open "select * from order",cnnord,1,2
rsord.addnew
rsord!orderid=txtoid.Text
rsord!DateOrdered=txtod.Text
rsord!CustomerId=txtcid.Text
rsord!QuatityOrdered=txtqo.Text
rsord!ProductTitle=txtPt.Text
rsord!PurchasedUnitPrice=txtpup.Text
rsord.update
if rsord.state=adstateopen then rsord.close
set rsord=nothing

OR

INSERT ORDER (OrderId,DateOrdered,CustomerId,QuatityOrdered,ProductTitle,PurchasedUnitPrice) VALUES(txtoid.Text,FORMAT(txtod.Text,"dd-MMM-yyyy"),txtcid.Text,VAL(txtqo.Text),txtPt.Text,
VAL(txtpup.Text))

hope this helps.

regards
Shouvik

your table "ORDER" is a SQL reserve word.. thats why it is an invalid sql statement...

see here or here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.