Results 1 to 2 of 2

Thread: [RESOLVED] Syntax Error in Insert Statement

  1. #1

    Thread Starter
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Resolved [RESOLVED] Syntax Error in Insert Statement

    Hello All

    This is really troubling me since morning. After 4 cups of Coffee and 2 cups of Tea I am still unable to spot the error....

    vb Code:
    1. '~~> Save data to database
    2.     Dim strSQL As String
    3.     Dim mobjConn    As ADODB.Connection
    4.     Dim mobjCmd     As ADODB.Command
    5.     Dim mobjRst     As ADODB.Recordset
    6.    
    7.     Set mobjConn = New ADODB.Connection
    8.     mobjConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    9.                               & "Data Source=c:\" & "LSS.mdb"
    10.     mobjConn.Open
    11.     Set mobjCmd = New ADODB.Command
    12.     Set mobjCmd.ActiveConnection = mobjConn
    13.     mobjCmd.CommandType = adCmdText
    14.    
    15.     strSQL = "INSERT INTO Table1 ("
    16.     strSQL = strSQL & "'" & DTPicker1.Value & "',"
    17.     strSQL = strSQL & "'" & Combo1.Text & "',"
    18.     strSQL = strSQL & "'" & Combo2.Text & "',"
    19.     strSQL = strSQL & "'" & Combo3.Text & "',"
    20.     strSQL = strSQL & "'" & Text1.Text & "',"
    21.     strSQL = strSQL & "'" & Text2.Text & "',"
    22.     strSQL = strSQL & "'" & Text3.Text & "',"
    23.     strSQL = strSQL & "'" & Combo4.Text & "',"
    24.     strSQL = strSQL & "'" & Combo5.Text & "')"
    25.  
    26.     '~~>MsgBox strSQL
    27.     mobjCmd.CommandText = strSQL
    28.     mobjCmd.Execute strSQL
    29.    
    30.     Set mobjRst = Nothing
    31.     Set mobjCmd = Nothing
    32.     mobjConn.Close
    33.     Set mobjConn = Nothing

    BTW I also tried this but no joy...

    vb Code:
    1. strSQL = "INSERT INTO Table1(  Date"
    2.         strSQL = strSQL & ", LoginID"
    3.         strSQL = strSQL & ", Advisor"
    4.         strSQL = strSQL & ", Verifier"
    5.         strSQL = strSQL & ", Customer"
    6.         strSQL = strSQL & ", ContactNo"
    7.         strSQL = strSQL & ", DebtAdvisor"
    8.         strSQL = strSQL & ", Client"
    9.         strSQL = strSQL & ", Program"
    10.         strSQL = strSQL & ") VALUES ("
    11.         strSQL = strSQL & "'" & DTPicker1.Value & "'"
    12.         strSQL = strSQL & ", '" & Combo1.Text & "'"
    13.         strSQL = strSQL & ", '" & Combo2.Text & "'"
    14.         strSQL = strSQL & ", '" & Combo3.Text & "'"
    15.         strSQL = strSQL & ", '" & Text1.Text & "'"
    16.         strSQL = strSQL & ", '" & Text2.Text & "'"
    17.         strSQL = strSQL & ", '" & Text3.Text & "'"
    18.         strSQL = strSQL & ", '" & Combo4.Text & "'"
    19.         strSQL = strSQL & ", '" & Combo5.Text & "')"

    Snapshot of the error is attached. Also attached is the snapshot of the table structure...

    Could it be possible because of the field called "Date"???
    Attached Images Attached Images   
    Last edited by Siddharth Rout; Jan 29th, 2010 at 03:55 AM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  2. #2

    Thread Starter
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Syntax Error in Insert Statement

    Got it... How Dumb!!!

    I answered my own question...

    I changed the Date column to Tdate and it worked...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width