dBase II connect via Visual Studio 2010
-
Tuesday, June 21, 2011 6:42 AM
Hi what is the best way to connect do dBase II using visual studio Microsoft ODBC Data Source (ODBC) dBase provider, but each time i am trying to connect to this database the visual studio freezes.
Can you help me how to connect to this database ?
All Replies
-
Tuesday, June 21, 2011 12:10 PM
I would try using the Microsoft Access Database File data source if your are creating a Data Connection. It's a little tricky because you have to open the Advanced... properties on the Add Connection dialog and then set the Extended Properties to "dBase IV". Then specify the folder path (no file name) in the Database file name TextBox of the Add Connection dialog. You can blank out the User name: field since it isn't needed.
Once you click OK to add the connection, all of the dBase files in the folder will show up in the Tables section of the connection under Server Explorer.
You can also use ADO.NET code to connect:
'Establish a connection to the data source. Dim ConnectionString As String 'ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ ' "Data Source=C:\Documents and Settings\...\My Documents\My Database\dbase;Extended Properties=dBase IV" ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=C:\Documents and Settings\...\My Documents\My Database\dbase;Extended Properties=dBase IV" Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString) dBaseConnection.Open() Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from Orders.dbf WHERE CUSTOMERID = UCase('Vinet')", dBaseConnection) Dim ds As New DataSet("dBaseTables") da.Fill(ds, "MydBase") '... Dim dt As DataTable dt = ds.Tables("MydBase") DataGrid1.DataSource = ds.Tables("MydBase") Dim drCurrent As DataRow For Each drCurrent In dt.Rows Console.WriteLine("{0} {1}", _ drCurrent("Column1").ToString, _ drCurrent("Column2").ToString) Next dBaseConnection.Close()
Paul ~~~~ Microsoft MVP (Visual Basic) -
Thursday, June 23, 2011 12:15 PM
Hi Paul,
i have tried your solution, but it wasn't working :( I have found a solution to connect via oledb . Here is the solution if someone would be interested
a) download VFPOLEDBSetup.msi
b) install with option to everyone !!!! on the computer (this is really important)
c) connect with oledb and also as you have written you need to Extend Properties to dBase III (probably dBase IV, would also work)
- Proposed As Answer by Paul P Clement IVMVP Thursday, June 23, 2011 12:58 PM
- Marked As Answer by Marian_P Thursday, June 23, 2011 1:12 PM
-
Wednesday, June 27, 2012 7:14 PM
Is there any instructions on how to simply import a dbf file into access? I know the VB 6 code, but that is not working in our Win 7 64 bit environment. So I am trying to convert our programs to VIsual Basic 2010 express.
Here is the VB 6 Code I am trying to convert.
Dim acApp As Access.Application
Set acApp = New Access.Application
acApp.OpenCurrentDatabase "D:\S\TestMDB.mdb", False
acApp.DoCmd.TransferDatabase acImport, "dBASE III", "D:\S\TestDBF.DBF", "tblTest"acApp.DoCmd.OpenQuery "qryTest"
acApp.CloseCurrentDatabase
acApp.Application.QuitI have been at this for weeks, and cannot figure out how to simply get this to work. I have tried different suggestions, and nothing is working. I am new to VB 2010, and only was an amatuare in VB 6.

