Link to home
Start Free TrialLog in
Avatar of podoboq
podoboq

asked on

How to convert Paradox Table into Access mdb file with VB?

Being totally ignorant, I need a complete solution here:

A [VB] script, macro, program or whatever they call it, that can be run with a command line parameter - a path to Paradox table and afterwards open that very table. Essentially I need to programatically open a Paradox table as if I called File->Open within Access, set the filter to Paradox (*.db), selected the file and opened it. I noticed that whenever a Paradox table is open, MS Access creates a respective mdb file containing the data of the original table, so I suppose I just need to open the Paradox table in order to convert it to mdb.

Thank you!
Avatar of rockiroads
rockiroads
Flag of United States of America image

ok, I know u said VB, but as a alternative, here are some paid solutions

1) there is this s/w called ABC Amber Paradox Converter. That might help u. Convert your tables to csv then import this csv into MSAccess

2) A more expensive utility http://www.ozgrid.com/Services/sql-server-database-convert.htm
ok, yet another non command line alternative

I read somewhere that there is a builtin paradox converter that comes with Access. Its in the data access pack folder ValuPack\DataAcc
I dont know if this can be used on the command line or not


Now I dont have Paradox but can u try this

1. Install ODBC drivers and setup a DSN to your Paradox database
2. Use ADO or something to read the Paradox tables, then write that data into Access
Avatar of podoboq
podoboq

ASKER

well, ODBC is not an option for me, as well as ABC Amber Convertor (its a handy tool though). Where should I search for this data access pack folder?
Avatar of podoboq

ASKER

Isnt there some simple way of calling Access with a macro name or something that just open a given paradox table?  I have to call this from within another program so command line or some other clever way of passing an argumant is a must
The pack should be on the CD, office CD I believe
u might even be able to download from the MS website
Avatar of podoboq

ASKER

okay, anyone?
Was the converter on the office cd any good?

Pity u cant use ODBC as that would solve a lot of your problems I think.
Avatar of podoboq

ASKER

>Was the converter on the office cd any good?
Well, i find this ValuPack\DataAcc for Office 97 on ms site but they dont mention any paradox cobverter.
ok, try this
how good is your ADO knowledge
Ive found a connection string that u may be able to use. I dont have Paradox so I cant test it
Ive then taken this connection string and built a simple loop, looping thru one table

Assumption: the database to be in C:\dbpath\



dim adoConn as New ADODB.Connection
dim adoRS as ADODB.Recordset


ON Error Resume Next

Err.Clear
'Note: There is an extra space after "db" in the Paradox Driver name, has to be that way
adoConn.Open "Driver={Microsoft Paradox Driver (*.db )};" & _
                      "DriverID=538;" & _
                      "Fil=Paradox 5.X;" & _
                      "DefaultDir=c:\dbpath\;" & _
                      "Dbq=c:\dbpath\;" & _
                      "CollatingSequence=ASCII"
if err.number <> 0 then
    msgbox "Connection Failure. " & err.Description
else
    set adoRS = New ADODB.Recordset
    adoRS.Open "SELECT * FROM somtable", adoConn, adOpenStatic, adLockPessimistic
    do while adoRS.EOF = False
        debug.print adoRS.Fields(0).Name, adoRS.Fields(0).Value
        adoRS.MoveNext
    loop
    adoRS.Close
    set adoRS = Nothing
    adoConn.CLose
end if
set adoCOnn = Nothing



Avatar of podoboq

ASKER

ok, how to pass the path to the table as an argument?
adoConn.Open "Driver={Microsoft Paradox Driver (*.db )};" & _
                      "DriverID=538;" & _
                      "Fil=Paradox 5.X;" & _
                      "DefaultDir=" & sDB & ";" & _
                      "Dbq=" & sDB & ";" & _
                      "CollatingSequence=ASCII"

sDB is the variable
Avatar of podoboq

ASKER

I mean, how to execute the macro with the path to the table as a command line argument. Is this possible?
Yes it is possible.  Use the Command$ variable in vb.

Let's say your compiled code is ConvertTables.exe, you would call it like this:

c:\ConvertTables.exe c:\Paradox\Tables\

Now, in your vb code, Command$ will contain "c:\Paradox\Tables\"
As leclairm has said, use Command

here is a pictorial tutorial to help u
http://www.vbexplorer.com/VBExplorer/vb_feature/august2000/command_line_arguments.asp
And if u wanted multiple command line arguments, its easier if I just show u a link with code examples
http://www.codeguru.com/vb/gen/vb_misc/tips/article.php/c2735/

Now with u asking this, can I assume that the code I posted earlier about opening via ado is working ?
Avatar of podoboq

ASKER

ekhem, really sorry, when I said VB, I meant VBA. Shall this work with VBA as well?
similar

In order to use command line parameters with MSAccess/VBA, u need to pass in using /cmd (http://support.microsoft.com/kb/209207)

Then in code u can use Command

Did that help then?

Did the ODBC connection to Paradox example code help you any?

Im guessing u are passing the name of the paradox database in

That example code, changed to using a variable

adoConn.Open "Driver={Microsoft Paradox Driver (*.db )};" & _
                      "DriverID=538;" & _
                      "Fil=Paradox 5.X;" & _
                      "DefaultDir=" & sDB & ";" & _
                      "Dbq=" & sDB & ";" & _
                      "CollatingSequence=ASCII"


Simply validate Command and set sDB to Command

sDB = Command

then try it
One question, u mentioned VBA, but question says VB
Are u using Access VBA?

If so then perhaps u could of used DoCmd.TransferDatabase

See this list as Paradox is a supported type

http://www.blueclaw-db.com/transferdatabase-docmd.htm
Avatar of podoboq

ASKER

Thank you very much for your time and efforts, rockiroads! That sounds very helpful. Indeed, im using Access VBA. Probably this thread was not the best place to post this question in. Anyway, the only thing left is to code the macro itself:) Can I write a standalone script that does the conversion, or rather have some "database" open and attach the macro to it or what? Being quite unfamiliar with Access and VBA I'm somewhat confused and dont know how to start off.
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial