I am trying to get external data from a paradox table directly into an array. But I have no idea where to start. I was trying to do it with a ADODB.connection and recordset but that doesn't seem to work since I am using a ODBC connection.
This is what I've got so far. But that doesn't work. Can somebody help me?Code:Sub Get_Data_Into_Array() 'A reference must be made to the Microsoft ActiveX Data Object Library x.x 'via Tools | References... in the VB-editor. Dim cnt As ADODB.Connection Dim rst As ADODB.Recordset Dim stSQL As String Dim vaData As Variant Dim i As Long, j As Long 'Instantiate the new ADO-objects. Set cnt = New ADODB.Connection Set rst = New ADODB.Recordset 'Create the SQL-statement stSQL = "SELECT * FROM HORDERRG" 'Connect to the databasesource. With cnt .Provider = "MSDASQL" .ConnectionString = "DSN=test2; DBQ=HORDERRG.DB" .Open End With 'Open the recordset. rst.Source = strSQL rst.ActiveConnection = cnt rst.Open 'Get some data about the recordset. With rst i = .Fields.Count j = .RecordCount End With 'Transfer the recordset to the array of variant-type. vaData = rst.GetRows() 'Testing purpose only Debug.Print UBound(vaData) + 1 'Due to 0-based array Debug.Print "Number of fields = " & i Debug.Print "Number of records = " & j 'Disconnect and empty memory. rst.Close Set rst = Nothing cnt.Close Set cnt = Nothing End Sub
-----------------
I had the wrong connectionstring
Last edited by AnnaAngel; 03-03-2010 at 07:36 AM.
this site may help http://software.informer.com/getfree...-blob-paradox/
regards pike
If the solution helped please donate here to the RSPCA
Sites worth visiting;
J&R Solutions - royUK
AJP Excel Information - Andy Pope
Spreadsheet Toolbox
JBeaucaires Excel Files
VBA for smarties - snb
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks