Insert INTO statement error

insert into syntax error (access database)

Page 1 of 1

4 Replies - 1688 Views - Last Post: 08 April 2010 - 04:55 AM Rate Topic: -----

#1 Queue   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-September 08

Insert INTO statement error

Posted 08 April 2010 - 02:08 AM

Hi,

i would just like to ask if my insert statement is correct..

when i run my program it returns me an error that says 'syntax error on my insert statement'. this syntax seems to work with sql database, but when i tried on access database it didn't work :(

can anyone help me with this?
straddemp = "insert into employee(empid, fname, mname, lname, gender, dob, age, citizenship, civilstat, address, contactno, emptype, department, position, sssno, tinno, fingerprint, dateadded, leave) values('" & txtempid.Text & "', '" & txtfname.Text & "', '" & txtmname.Text.Substring(0, 1).ToUpper & "." & "', '" & txtlname.Text & "', '" & cbgender.Text & "', '" & dtpdob.Text.ToString & "','" & txtage.Text & "', '" & txtcitiz.Text & "', '" & cbcivilstat.Text & "', '" & txtaddress.Text & "', '" & txttelno.Text & "', '" & cbemptype.Text & "', '" & cbdept.Text & "', '" & cbposition.Text & "', '" & txtsss.Text & "', '" & txttin.Text & "', '" & "Unregistered" & "', '" & Date.Now.ToString("MMM / d / yyyy") & "', '" & 15 & "')"


thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Insert INTO statement error

#2 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Insert INTO statement error

Posted 08 April 2010 - 02:16 AM

use # not ' on your data and see if it work
Was This Post Helpful? 1
  • +
  • -

#3 Queue   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-September 08

Re: Insert INTO statement error

Posted 08 April 2010 - 03:40 AM

i tried but it didn't work..


i researched and found out what was causing the problem.
the 'position' column in my table is a reserved word for microsoft jets 4.0 i tried changing the column name and it worked.

anyway, thanks for helping =)

This post has been edited by Queue: 08 April 2010 - 03:42 AM

Was This Post Helpful? 0
  • +
  • -

#4 PennyBoki   User is offline

  • D.I.C Lover
  • member icon

Reputation: 55
  • View blog
  • Posts: 2,345
  • Joined: 11-December 06

Re: Insert INTO statement error

Posted 08 April 2010 - 03:51 AM

Ok I am not sure, but you may want to take a look at your Date.Now.ToString("MMM / d / yyyy")
maybe you should separate that string in order to get the year then the month then the day and then format it in this way #YYYY-MM-DD#
Was This Post Helpful? 1
  • +
  • -

#5 Queue   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 06-September 08

Re: Insert INTO statement error

Posted 08 April 2010 - 04:55 AM

@sir PennyBoki
i tried what you said and i think the format it's better now! :D Thank you very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1