?
Solved

Connecting to a Paradox database with VB

Posted on 2000-04-03
5
Medium Priority
?
290 Views
Last Modified: 2010-05-02
I am trying to write a VB program that connects to a Paradox database to extract information. I have looked at the online help but I am not getting anywhere with it.
I can connect to a Access database and extract information from that with no problem, but I cannot connect to a Paradox DB in the same way.
Can anyone tell me what I need to do?
0
Comment
Question by:tonytaylor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Voodooman
ID: 2679352
Hi!

The easiest way is to Set the Connect property of the data control to Paradox. This will allow you to

However if you need to query data into and from Access to Paradox you need to attach the table.

If you have the retail version of Access you should right mouse click the table tab and select link tables and use this to attach your Paradox tables.

You can also attach this in code by using the tabledefs object

Set NewTD=myDb.CreateTableDef("NewtableName")

Newtd.sourcetablename=("ParadoxtableName")
NewTD.Connect="Paradox 4.x;Database=C:\Mydir\Mydb;"

Mydb.Append NewTD

This will attach the table to your Access database.

This is the correct answer

Thanks in Advance for the points

Voodooman!
0
 

Author Comment

by:tonytaylor
ID: 2679488
Thanks for your swift response, Voodooman.
Your answer would help me to link an Access db to a Paradox one, but I am not sure if I was clear enough in my question.
What I need to do is connect to a Paradox db and extract information from it with a VB program (probably using a SELECT statement) and then write this information to a text file.
If you could give me the code to connect and extract info from a Paradox db I will increase the points value of the question.
Also is there any difference between version 7 of Paradox and earlier versions?
Thanks.
0
 
LVL 5

Accepted Solution

by:
Voodooman earned 450 total points
ID: 2683111
Hi!

if you want to query the Paradox table set the data source to an sql string.

i.e.
mydatacontrol.DATASource="Select * from stock"

mydatacontrol.refresh

Here is some code that writes a csv

This includes the field names selectively - you could do this with the SQL if you want

Public Function ExportStockTable() As Boolean

Dim rs As dao.Recordset
Dim filestr As String
Dim GetDir As String
Dim recstr As String

On Error GoTo E:


'make sure the Export Directory exists
'if not create it
'*****************
GetDir = Dir(Envobj.ProgramLocation & "Export", vbDirectory)
If GetDir = "" Then
    MkDir Envobj.ProgramLocation & "Export"
    End If
   
filename = Envobj.ProgramLocation & "Export\Stock.txt"

'now create the blank file or if it exists clear it
'**************************************************
Open filename For Output As #1
Close #1

'Set the data
'************
Set rs = data_Stock.recordset

If rs.RecordCount = 0 Then
   Imessage "No Stock Records to Export!"
   Exit Function
End If

Open filename For Append As #1

'Add the first row with the table names
'**************************************
Print #1, "Code,Date,Supplier,Label,Description,Category,SizeRange,Size,Sell Price,VatRate,Colour,BuyPrice,Style,StyleName"

Do Until rs.EOF

For I = 0 To rs.Fields.Count - 1

'Select the field names for the Export
'*************************************
Select Case rs(I).Name
    Case "Code", "Date", "Supplier", "Label", "Description", "Category", "SizeRange", "Size", "Sell Price", "VatRate", "Colour", "BuyPrice", "Style", "StyleName"
        'if its Text
            '***********
            If rs.Fields(I).Type = dbText Then
                If IsNull(rs.Fields(I)) Then
                recstr = recstr & Chr(34) & Chr(34)
                Else
                recstr = recstr & Chr(34) & rs.Fields(I) & Chr(34)
                End If
            End If
           
            'if its date
            '***********
            If rs.Fields(I).Type = dbDate Then
                If Not IsNull(rs.Fields(I)) Then
                recstr = recstr & rs.Fields(I)
                End If
            End If
           
             'if its not text and not date
            '******************************
            If rs.Fields(I).Type <> dbText And rs.Fields(I).Type <> dbDate Then
                If Not IsNull(rs.Fields(I)) Then
                recstr = recstr & Format$(rs.Fields(I))
                End If
            End If
recstr = recstr & ","
End Select


Next I

'trim the last comma off the end
'*******************************
recstr = Left(recstr, Len(recstr) - 1)


Print #1, recstr
recstr = ""

rs.MoveNext
Loop

DoEvents

Close #1


ExportStockTable = True

Exit Function

E:
Emessage "An error has occurred writing Stock.txt!"
Exit Function


End Function


Good Luck

Voodooman!


0
 

Author Comment

by:tonytaylor
ID: 2686595
Adjusted points from 100 to 150
0
 

Author Comment

by:tonytaylor
ID: 2686596
Thanks Voodooman.
Your answers helped me to do what I need so far. I may well be back with more questions later.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 12 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question