Problems with ADO from Excel

E

Elias

I am trying to run the following code and I get an error with the following
details:

Runtime Error -2147467259
Automation Error
Unspecified Error

The code looks like the following

Dim wrkRange As Range
Dim last As Integer
Dim i As Integer
Dim MyConn As ADODB.Connection
Dim strConn As String
Dim rstDocs As ADODB.Recordset

Sub ParseContent()
'Get the working Range
Set wrkRange = Application.InputBox("Enter the active range", "Range
Selector", , , , , , 8)
'Find the last cell number
last = wrkRange.Rows.Count
'Opening Database File
'Dim MyConn As New ADODB.Connection
'Dim strConn As String

Set MyConn = New ADODB.Connection
strConn = "Provider=SQLOLEDB;Server=Cronos;" & _
"Database=Papyrus;Integrated Security='SSPI';"

MyConn.Open strConn

'Dim rstDocs As ADODB.Recordset
Set rstDocs = New ADODB.Recordset

rstDocs.Open "Docs", MyConn, adOpenKeyset, adLockOptimistic, adCmdTable


'Start Filling the access database
'Columns A+B to Docs Table
For i = 1 To last
Dim strfield As String

strfield = wrkRange.Cells(i, "A")
rstDocs.MoveLast
rstDocs.AddNew Key_Id, strfield
rstDocs.Update



Next i

End Sub

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top