Click here to Skip to main content
15,912,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
ssql = "insert into inward_master(inwardno,inwdate,intype,site,dept,sguard,vehno,str_recby,enterby) values" & _
           "('" & Me.txtinward.Text & "' ,'" & Format(Me.dtinward.Value, "MM/dd/yyyy") & "'," & _
           "'" & Me.cmbintype.Text & "'," & _
           "'" & loginsite & "','" & Me.txtdeptno.Text & "'," & _
           "'" & Me.txtsg.Text & "'" & _
           "'" & Me.txtveh.Text.Trim & "'" & _
           ",'" & Me.txtrec.Text & "', '" & login & "')"


when i execute query then it says.there are more col in ur insert statment.then values.

plz help me
Posted

There is 10 items in your columns list but you are inserting only 9.

The str could be extra.
 
Share this answer
 
Comments
André Kraak 1-Nov-11 4:43am    
Are you sure? I only counted eight ',' in the columns list.

I did find one missing ',' in the values list, see my solution.
Mehdi Gholam 1-Nov-11 4:51am    
It's a pain to see code like this, you get cross eyed :)
André Kraak 1-Nov-11 4:56am    
You are right, I had to count it three times.
prince_rumeel 1-Nov-11 5:16am    
thanks alot all of u
Espen Harlinn 1-Nov-11 13:27pm    
5'ed!
First start by changing this line
VB
"'" & Me.txtsg.Text & "'" & _

and adding a ',' to them
VB
"'" & Me.txtsg.Text & "'," & _

Now see what happens.

You might want to change your code so that you are consistent in how you add the ' and , to the statement. The way it is now is very hard to read.

Also you might want to look into to parameterized queries[^].

And as a final note do not store date as a string but use the datetime type[^].
 
Share this answer
 
v3
Comments
Mehdi Gholam 1-Nov-11 4:51am    
5'ed
André Kraak 1-Nov-11 4:56am    
Thank you.
RaisKazi 1-Nov-11 5:11am    
A 5!
prince_rumeel 1-Nov-11 5:16am    
thanks andre kraak
Espen Harlinn 1-Nov-11 13:27pm    
5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900