Results 1 to 4 of 4

Thread: [RESOLVED] Help needed to solve syntax error problem

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Resolved [RESOLVED] Help needed to solve syntax error problem

    I've a problem with a syntax error with the Insert statement, and I
    can't seem to track it down, do you have any Ideas?

    here is the section that is causing problems:
    VB Code:
    1. Private Sub cmdProcess_Click()
    2.     Dim cn As New ADODB.Connection
    3.     Dim SQLSTRING As String
    4.     cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\StarTrader\STOCKDATAASX.MDB"
    5.  
    6.     Debug.Print cn
    7.  
    8.     Dim tblCode As String
    9.     Open "c:\program files\startrader\xtg\data.txt" For Input As #1
    10.     Input #1, code, nodate, openp, high, low, closep, volume
    11.  
    12.     Do Until (EOF(1) = True)
    13.         Debug.Print code
    14.         Debug.Print nodate
    15.         Debug.Print openp
    16.         Debug.Print high
    17.         Debug.Print low
    18.         Debug.Print closep
    19.         Debug.Print volume
    20.         tblCode = code
    21.         Debug.Print tblCode
    22.         SQLSTRING = "INSERT INTO " & tblCode & "(Code,TradeDate,Open,High,Low,Close,Volume) VALUES(" & """" & code & """" & "," & "#" & ddate & "#" & "," & openp & "," & high & "," & low & "," & closep & "," & volume & ")"
    23.         Debug.Print SQLSTRING
    24.         cn.Execute SQLSTRING
    25.         code = ""
    26.         nodate = ""
    27.         openp = 0
    28.         high = 0
    29.         low = 0
    30.         closep = 0
    31.         volume = 0
    32.         Input #1, code, nodate, openp, high, low, closep, volume
    33.     Loop
    34.     Close #1
    35. End Sub
    Thanks in advance.

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Help needed to solve syntax error problem

    open and close are reserved words so do this:
    VB Code:
    1. Code,TradeDate,[Open],High,Low,[Close],Volume

  3. #3

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: Help needed to solve syntax error problem

    Quote Originally Posted by BrailleSchool
    open and close are reserved words so do this:
    VB Code:
    1. Code,TradeDate,[Open],High,Low,[Close],Volume
    Thank you, I racked my brain and library for hours on this one. I guess I should have walked away for awhile.

  4. #4

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