Results 1 to 2 of 2

Thread: Problems with SQL statements

  1. #1

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Question

    I'm trying to transport data from one file to a database. The program worked fine a few weeks ago but when I've come to use it, the following error message occurs:

    "Syntax Error in INSERT INTO statement"

    Here's the code for the module:
    Option Explicit


    Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
    Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
    Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long

    Public Const MAX_PATH = 260

    Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
    End Type
    Type WIN32_FIND_DATA
    dwFileAttributes As Long
    ftCreationTime As FILETIME
    ftLastAccessTime As FILETIME
    ftLastWriteTime As FILETIME
    nFileSizeHigh As Long
    nFileSizeLow As Long
    dwReserved0 As Long
    dwReserved1 As Long
    cFileName As String * MAX_PATH
    cAlternate As String * 14
    End Type

    Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
    Public Const FILE_ATTRIBUTE_NORMAL = &H80

    Public Sub WriteToDB(StarDateTime As String, EndDateTime As String, DurationSecs As String, CallersNumber As String, DialledNumber As String, TerminatingNumber As String, ValuePence As String)

    Dim DBconnect As Database
    Dim Query As String
    Dim Resultset As Recordset

    'connect to database
    Set DBconnect = OpenDatabase("D:\OPAL_CDR_data_ftp.mdb")

    'Standard Query
    Query = "INSERT INTO Opal_CDR_data/July 2000(StarDateTime, EndDateTime, DurationSecs, CallersNumber, DialledNumber, TerminatingNumber, ValuePence) Values('" & StarDateTime & "','" & EndDateTime & "','" & DurationSecs & "','" & CallersNumber & "','" & DialledNumber & "','" & TerminatingNumber & "','" & ValuePence & "')"

    ******//HERES WHERE THE PROBLEMS BEGIN//******************


    DBconnect.Execute (Query)

    End Sub



    As far as I can see the syntax is ok but does anyone know whats goining on.

    Cheers n beers
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    That forward slash might be screwing up the engine, try this instead:

    INSERT INTO [Opal_CDR_data/July 2000] (StarDateTime....

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