3 Replies - 12916 Views - Last Post: 25 March 2011 - 05:08 AM Rate Topic: -----

#1 Born2Hack  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-February 11

SYNTAX ERROR IN INSERT INTO STATEMENT

Posted 25 March 2011 - 12:47 AM

Option Explicit
Dim con as connection
Dim rec as recordset

Pivate Sub Form_Load()
Set con = new connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database.mdb;Persist Security Info=False"
Set rec = new recordset


rec.Open "insert into user (e_id,e_sname,e_fname,e_mi,e_status,e_gender,e_address,e_pass) values (" & Text1.Text & ",'" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Combo1.Text & "','" & Combo2.Text & "','" & Text6.Text & "','" & Text7.Text & "')", con, adOpenStatic, adLockOptimistic


This is my code , but when i run it , error box appear and it say RUN TIME ERROR . SYNTAX ERROR IN INSERT INTO STATEMET? But why ? in my database , e_id is the only number. . GUYS PLEASE HELP :)

Is This A Good Question/Topic? 0
  • +

Replies To: SYNTAX ERROR IN INSERT INTO STATEMENT

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,778
  • Joined: 26-March 09

Re: SYNTAX ERROR IN INSERT INTO STATEMENT

Posted 25 March 2011 - 03:32 AM

try assigning your query to a string variable then printing it in the immediate window to validate it looks correct.

dim strSQL as string
strSQL = "insert into user (e_id,e_sname,e_fname,e_mi,e_status,e_gender,e_address,e_pass) values (" & Text1.Text & ",'" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Combo1.Text & "','" & Combo2.Text & "','" & Text6.Text & "','" & Text7.Text & "')"

debug.print strSQL

Was This Post Helpful? 0
  • +
  • -

#3 Born2Hack  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-February 11

Re: SYNTAX ERROR IN INSERT INTO STATEMENT

Posted 25 March 2011 - 04:56 AM

View Postmaj3091, on 25 March 2011 - 03:32 AM, said:

try assigning your query to a string variable then printing it in the immediate window to validate it looks correct.

dim strSQL as string
strSQL = "insert into user (e_id,e_sname,e_fname,e_mi,e_status,e_gender,e_address,e_pass) values (" & Text1.Text & ",'" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Combo1.Text & "','" & Combo2.Text & "','" & Text6.Text & "','" & Text7.Text & "')"

debug.print strSQL


@maj3091 ,Hey , its running , but it doesnt add to my database ? what should i do ? by the way thank you for replying :))
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,778
  • Joined: 26-March 09

Re: SYNTAX ERROR IN INSERT INTO STATEMENT

Posted 25 March 2011 - 05:08 AM

You haven't really changed anything in your code, this was just a way of looking at your SQL query.

Can you paste what you got in the immediate window please.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1