Connection to dBase file but not using .dbf extentions

A

Andy

Hey all, Was wondering if there is another parameter to pass along with the
rest of the connection string to have Jet look for a dBase connection using
something other than .dbf?

Here's my conn string for reference...

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & cDataPath & ";Extended
Properties=dBASE IV;"

We just happen to use the extension .DAT for all of our database files.

Thanks in Advance for the help.

Andy
 
P

Paul Clement

¤ Hey all, Was wondering if there is another parameter to pass along with the
¤ rest of the connection string to have Jet look for a dBase connection using
¤ something other than .dbf?
¤
¤ Here's my conn string for reference...
¤
¤ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & cDataPath & ";Extended
¤ Properties=dBASE IV;"
¤
¤ We just happen to use the extension .DAT for all of our database files.
¤

I don't believe the driver will recognize the file with a different extension. There was a
workaround in DAO, by including the file and extension separated by #, but I don't believe that
works with Jet OLEDB and the ISAM driver. Haven't tried it using ODBC.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
C

Cindy Winegarden

Hi Andy,

Here's some code that works for me. I'm using the FoxPro and Visual FoxPro
OLE DB data provider, downloadable from
http://msdn.microsoft.com/vfoxpro/downloads/updates/default.aspx.

Module Module1

Sub Main()

Dim conn As New System.Data.OleDb.OleDbConnection( _
"Provider=VFPOLEDB.1;Data Source=C:\Temp;" & _
"Persist Security Info=False;")
conn.Open()

'----------------
'-- Part 1
'-- Uncomment this code on the first pass
'-- to create the table.
'-- Then rename the table to the .dat extention and go on to part 2.

'Dim sqlCommand1 As New System.Data.OleDb.OleDbCommand( _
' "Create Table TestExtention (Field1 I, Field2 C(10))", _
' conn)
'sqlCommand1.ExecuteNonQuery()

'Dim sqlCommand2 As New System.Data.OleDb.OleDbCommand( _
' "Insert Into TestExtention Values (1, 'Hello')", _
' conn)
'sqlCommand2.ExecuteNonQuery()
'Dim sqlCommand3 As New System.Data.OleDb.OleDbCommand( _
' "Insert Into TestExtention Values (2, 'World')", _
' conn)
'sqlCommand3.ExecuteNonQuery()

'----------------
'-- Part 2
'-- Comment out the above code and uncomment this code
'-- to see if you can read the .dat table.

'Dim da As New System.Data.OleDb.OleDbDataAdapter( _
' "Select * From TestExtention.dat", _
' conn)
'Dim ds As DataSet = New System.Data.DataSet
'da.Fill(ds)

'Dim dr As DataRow
'For Each dr In ds.Tables(0).Rows
' Console.WriteLine(dr("Field1").ToString() & " " &
dr("Field2").ToString())
'Next

Stop ' For testing

End Sub

End Module
 

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