|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL error message
Hi Guys. I've been wanting to import a weird file into access with a header followed by columns of data . . Like the following . . .
Count interval: 15 min Detector: Tube Vehicle interval: n/a Counter No: 3008 Firmware version: 2.04 Counter read at: 13:16:51 on 15/06/2004 First count recorded at: 16:00:00 on 11/06/2004 Last count ended at: 13:15:00 on 15/06/2004 Total vehicles recorded: 44696 Total axles recorded: 89429 Detector spacing: 1000mm Channel 1 Site log: Žempty¯ __________________________________________________ ____________________ Date Time Cl Spd Unclass 11/06 16:00 1 63 11/06 16:00 1 64 11/06 16:00 1 60 11/06 16:00 1 59 11/06 16:00 1 56 11/06 16:00 1 54 11/06 16:00 1 61 11/06 16:00 1 63 11/06 16:00 1 61 11/06 16:00 1 54 11/06 16:00 1 56 11/06 16:00 1 56 11/06 16:00 1 55 11/06 16:00 1 55 11/06 16:00 1 61 11/06 16:00 1 59 The error occured next to the bold Anyway I get the following error, "Runtime error: 3061" "Too few parameters. Expected 1". Does anyone know what this would mean? The code is below . .. . Option Compare Database Private Sub Command0_Click() Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim sql As String Dim buf As String ' ' Open your file ' Open "C:\Documents and Settings\Steve\Desktop\counterDB\Speed TBL's\104.TBL" For Input As #1 ' ' Skip until there's a date ' buf = "Starting ..." While (Not IsDate(Mid(buf, 1, 5))) And Not EOF(1) Line Input #1, buf Wend If EOF(1) Then MsgBox ("Problems with the file.") Exit Sub End If ' ' Process the file ' ' +- Field1 ' | ' TheDate | +- Field2 ' | | | ' V V V '=========== = == '11/06 16:00 1 63 '11/06 16:00 1 64 '11/06 16:00 1 60 Set dbs = CurrentDb While Not EOF(1) ' ' Does it exist in your table? ' sql = "SELECT * " & _ "FROM SpeedImport " & _ "WHERE Date = #" & Mid(buf, 1, 5) & "# AND " & _ "Time = #" & Mid(buf, 7, 5) & "# AND " & _ "Cl = " & Mid(buf, 14, 1) & " AND " & _ "Speed = " & Mid(buf, 16, 3) Set rst = dbs.OpenRecordset(sql) If rst.EOF And rst.BOF Then ' ' It is new, add it ' rst.AddNew rst!Date = Mid(buf, 1, 5) rst!Time = Mid(buf, 7, 5) rst!Cl = Mid(buf, 14, 1) rst!Speed = Mid(buf, 16, 3) rst.Update Else ' ' It is already there, leave it ' End If Set rst = Nothing Line Input #1, buf ' Retrieve next line Wend Close #1 End Sub Thanks |
|
#2
|
|||
|
|||
|
I've made some changes since then. Fields "Date" and "Time" have been changed to "RecordDate" and "RecordTime" respectively. Still got the same problem tho
![]() |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > SQL error message |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|