[AccessD] still struggling with inserting to access table

Brock, Christian T, HRC-Alexandria Christian.Brock at hoffman.army.mil
Thu Oct 16 11:13:00 CDT 2003


Are any of the values strings?  If so they need to be wrapped in single
quotes.

Values('" & aRecord(0) & "', " &...

Christian Brock

-----Original Message-----
From: Oleg_123 at xuppa.com [mailto:Oleg_123 at xuppa.com] 
Sent: Thursday, 16 October 2003 11:52
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] still struggling with inserting to access table


hmmm, this is getting better, its on the right track
Now I got "to few parameters" error, Even so there are 5 clumns in the
table, and  Iimporting 5 fields


Dim db As DAO.Database
Set db = CurrentDb
strSQL = "INSERT into Table1Testing(a, b, c, d, e) Values(" & aRecord(0) &
"," & aRecord(1) & "," & aRecord(2) & "," & aRecord(3) & "," & aRecord(8)
& ")"
db.Execute (strSQL)




> hmmmm, don't know what to suggest unless you use DAO then
> Dim db as DAO.Database
> Set db = CurrentDB
> db.Execute(strSql)
> Paul
>
>
>
>
> Message date : Oct 16 2003, 04:13 PM
>>From : Oleg_123 at xuppa.com
> To : accessd at databaseadvisors.com
> Copy to :
> Subject : Re: Re: [AccessD] still struggling with inserting to access
> table  I do not have CurrentProject available (i am Access 97, i put
> reference on  Object 2.5 Lirary) I've selected CurrentDB.Connection, but
> get the error  message --
> Operation not supported for this type of object
>
>> try adding this line after
>> Dim con As New ADODB.Connection
>> Set con = CurrentProject.Connection
>> This tells it to use the current database.
>> Paul
>>
>>
>>
>>
>> Message date : Oct 16 2003, 03:34 PM
>>>From : Oleg_123 at xuppa.com
>> To : accessd at databaseadvisors.com
>> Copy to :
>> Subject : Re: [AccessD] still struggling with inserting to access
>> table  I thought I was using the default connection ?
>>
>> Also I tried it using this
>> DoCmd.RunSQL "INSERT into Table1Testing(a,b) Values(" & aRecord(0) &
>> ",  " & aRecord(8) & ")"
>>
>> but I get some pitiful results :(
>>
>>> As far as I can see you haven't setup a connection into the database
>>> for the con variable, so it would be closed when you try the command
>>> con.execute. Paul
>>>
>>>
>>>
>>>
>>> Message date : Oct 16 2003, 02:59 PM
>>>>From : Oleg_123 at xuppa.com
>>> To : accessd at databaseadvisors.com
>>> Copy to :
>>> Subject : [AccessD] still struggling with inserting to access table I
>>>  still haven't done this inseting of .csv in access table (had other
>>> things to do first)Those 2 lines still dont work
>>> strSQL = "INSERT into Table1Testing(a,b) Values(" & aRecord(0) & ","
>>> & aRecord(8) & ")"
>>> con.Execute (strSQL)
>>>
>>> whats wrong here ? When I run similar message from query window it
>>> works fine. This way I get "Operation is not allowed when the object
>>> is closed" error. # 3704 (the first part works more or less
>>> correctly)
>>>
>>> Dim fs As New Scripting.FileSystemObject
>>> Dim ts As Scripting.TextStream
>>> Dim strLine As String
>>> Dim aRecord
>>> Dim strSQL As String
>>> Dim con As New ADODB.Connection
>>>
>>> If fs.FileExists("U:\Users\HRIS\oleg\cars testing\trainFROM.csv")
>>> Then
>>>
>>>
>>> Set ts = fs.OpenTextFile("U:\Users\HRIS\oleg\cars
>>> testing\trainFROM.csv", ForReading)
>>>
>>> Do Until ts.AtEndOfStream
>>>
>>> strLine = ts.ReadLine
>>> 'strline =
>>> aRecord = Split(strLine, ",")
>>> aRecord(8) = Mid(aRecord(8), 5) & Left(aRecord(8), 4)
>>> Debug.Print aRecord(6) & " " & aRecord(7) & " " & aRecord(8)
>>>
>>> strSQL = "INSERT into Table1Testing(a,b) Values(" & aRecord(0) & ","
>>> & aRecord(8) & ")"
>>> con.Execute (strSQL)
>>>
>>> Loop
>>> Else
>>> MsgBox ("file doesn't exist")
>>> End If
>>>
>>>
>>>
>>> -----------------------------------------
>>> Get Breaking News from CNN, ABC, NBC, CBS Now.
>>> http://www.xuppa.com/news/?link=webmail
>>>
>>>
>>> _______________________________________________
>>> AccessD mailing list
>>> AccessD at databaseadvisors.com
>>> http://databaseadvisors.com/mailman/listinfo/accessd
>>> Website: http://www.databaseadvisors.com
>>
>>
>>
>> -----------------------------------------
>> Get Breaking News from CNN, ABC, NBC, CBS Now.
>> http://www.xuppa.com/news/?link=webmail
>>
>>
>> _______________________________________________
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>
>
>
> -----------------------------------------
> Get Breaking News from CNN, ABC, NBC, CBS Now.
> http://www.xuppa.com/news/?link=webmail
>
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



-----------------------------------------
Get Breaking News from CNN, ABC, NBC, CBS Now.
http://www.xuppa.com/news/?link=webmail


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list