|
|
|
date: Sun, 9 Apr 2006 04:47:01 -0700,
group: microsoft.public.dotnet.datatools
back
Re: How to use dbf file in Data Adapter Configuration Wizard
Dear Cindy,
Thank you for quick response. Ok I now understand that I don't have to use
ODBC. I have a few questions.
1) Is the Provider "VFPOLEDB" common for DOS BASE applicaiton FoxPro 2.6 and
Visual Fox Pro? Is there a separate provider for FoxPro 2.6?
2) On MSDN help "Opening a Database" I could find that it is possible to
connect
external database using suitable Extended Properties as under:
MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\BOOKING.DBF;Extended Properties=dBASE IV;")
I get an error as below with above Myconnection code
'c:\BOOKING.DBF' is not a valid path. Make sure that the path name is spelled
correctly and that you are connected to the server on which the file resides.
What could be wrong? The path is absolutely correct. I also put the path on
the
like "servername\fpdb\booking.dbf" but it says the same error.
3) When I use Excel like
MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\BOOKING.XLS;Extended Properties=Excel 3.0;")
I get error as under:
External table is not in the expected format.
Please advise.
Thank you,
Rakesh
"Cindy Winegarden" wrote:
> Hi Rakesh,
>
> Since you're working in a .NET language it's time to get away from ODBC,
> which is a deprecated data access technology. The FoxPro and Visual FoxPro
> OLE DB data provider will work correctly with all Fox tables. Since you're
> using FPD 2.6 tables your connection string should point to the directory
> where the tables are. Then you can use code like this:
>
> '-- -------------------------------------------
> Imports System
> Imports System.Data
> Imports System.Data.OleDb
>
> Module Module1
>
> Sub Main()
>
> Dim cn As New OleDbConnection( _
> "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
> cn.Open()
>
> Dim cmd1 As New OleDbCommand( _
> "Create Table TestDBF (Field1 C(10))", cn)
> Dim cmd2 As New OleDbCommand( _
> "Insert Into TestDBF Values ('Hello')", cn)
> Dim cmd3 As New OleDbCommand( _
> "Insert Into TestDBF Values ('World')", cn)
> cmd1.ExecuteNonQuery()
> cmd2.ExecuteNonQuery()
> cmd3.ExecuteNonQuery()
> Dim cmd4 As New OleDbCommand("Select * From TestDBF", cn)
> Dim r1 As OleDbDataReader = cmd4.ExecuteReader()
> Dim Field1Data As String = ""
> While r1.Read()
> Field1Data += r1.GetString(0) + vbCrLf
> End While
>
> MsgBox(Field1Data.ToString())
>
> r1.Close()
> cn.Close()
>
> End Sub
>
> End Module
> '-- -------------------------------------------
>
>
> --
> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> cindy_winegarden@msn.com www.cindywinegarden.com
>
>
> "Rakesh Parekh" wrote in message
> news:937476CB-68AD-4ADA-931B-9610688901F6@microsoft.com...
> > Dear Cindy,
> >
> > It works fine when I use following connection.
> >
> > MyConnection = New
> > Microsoft.Data.Odbc.OdbcConnection("Provider=MSDASQL;DSN=mydBase")
> >
> > But I do not want to use a DSN. Instead I want to use a server path like
> >
> > " \\fpdb\booking.dbf "
> >
> > How do I tell the connection to refer server path "\\fpdb\booking.dbf" and
> > where do I put it?. Pls advise.
>
>
>
date: Sun, 16 Apr 2006 02:13:01 -0700
author: Rakesh Parekh
Re: How to use dbf file in Data Adapter Configuration Wizard
Hi Rakesh,
1. As I said below, "The FoxPro and Visual FoxPro OLE DB data provider will
work correctly with all Fox tables."
2. As I said below, "Since you're using FPD 2.6 tables your OLE DB
connection string should point to the directory where the tables are. Then
you can use code like this: ....."Provider=VFPOLEDB.1;Data
Source=C:\Temp\;")". DO NOT use the table name in the connection string.
Only point to the directory. The place to specify the table name in a Select
statement like: "("Select * From TestDBF", cn)" This is so you can use one
connection string to access all of the Fox tables in that directory.
The Jet ODBC driver works with a whole bunch of different types of tables.
Thus you need to specify the type of table (dBase IV, Excel) using the
Extended Properties clause. If you're working with the VFPOLEDB data
provider then you are not working with Jet. You do not use the same type of
connection string; for example, you don't use the Extended Properties
clause. The VFPOLEDB data provider already knows it's working with some
version of FoxPro DBF, and it's built to figure out which version of DBF and
go from there.
I'm not all that familiar with Jet connection strings for Excel. For your
Excel example I see you've specified "Extended Properties=Excel 3.0;". Excel
from Office 2003 is Excel 11 so that means Excel 3 is pretty old. Perhaps
your tables were created with a more recent version of Excel.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
"Rakesh Parekh" wrote in message
news:DE77E1F7-0DE5-4109-8B86-EE7B5605695F@microsoft.com...
> Dear Cindy,
>
> Thank you for quick response. Ok I now understand that I don't have to use
> ODBC. I have a few questions.
>
> 1) Is the Provider "VFPOLEDB" common for DOS BASE applicaiton FoxPro 2.6
> and
> Visual Fox Pro? Is there a separate provider for FoxPro 2.6?
>
> 2) On MSDN help "Opening a Database" I could find that it is possible to
> connect
> external database using suitable Extended Properties as under:
>
> MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=c:\BOOKING.DBF;Extended Properties=dBASE IV;")
>
> I get an error as below with above Myconnection code
>
> 'c:\BOOKING.DBF' is not a valid path. Make sure that the path name is
> spelled
> correctly and that you are connected to the server on which the file
> resides.
>
> What could be wrong? The path is absolutely correct. I also put the path
> on
> the
> like "servername\fpdb\booking.dbf" but it says the same error.
>
> 3) When I use Excel like
>
> MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=c:\BOOKING.XLS;Extended Properties=Excel 3.0;")
>
> I get error as under:
>
> External table is not in the expected format.
>
> Please advise.
> Thank you,
> Rakesh
>
> "Cindy Winegarden" wrote:
>
>> Hi Rakesh,
>>
>> Since you're working in a .NET language it's time to get away from ODBC,
>> which is a deprecated data access technology. The FoxPro and Visual
>> FoxPro
>> OLE DB data provider will work correctly with all Fox tables. Since
>> you're
>> using FPD 2.6 tables your connection string should point to the directory
>> where the tables are. Then you can use code like this:
>>
>> '-- -------------------------------------------
>> Imports System
>> Imports System.Data
>> Imports System.Data.OleDb
>>
>> Module Module1
>>
>> Sub Main()
>>
>> Dim cn As New OleDbConnection( _
>> "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
>> cn.Open()
>>
>> Dim cmd1 As New OleDbCommand( _
>> "Create Table TestDBF (Field1 C(10))", cn)
>> Dim cmd2 As New OleDbCommand( _
>> "Insert Into TestDBF Values ('Hello')", cn)
>> Dim cmd3 As New OleDbCommand( _
>> "Insert Into TestDBF Values ('World')", cn)
>> cmd1.ExecuteNonQuery()
>> cmd2.ExecuteNonQuery()
>> cmd3.ExecuteNonQuery()
>> Dim cmd4 As New OleDbCommand("Select * From TestDBF", cn)
>> Dim r1 As OleDbDataReader = cmd4.ExecuteReader()
>> Dim Field1Data As String = ""
>> While r1.Read()
>> Field1Data += r1.GetString(0) + vbCrLf
>> End While
>>
>> MsgBox(Field1Data.ToString())
>>
>> r1.Close()
>> cn.Close()
>>
>> End Sub
>>
>> End Module
>> '-- -------------------------------------------
date: Mon, 17 Apr 2006 13:03:53 -0400
author: Cindy Winegarden
Re: How to use dbf file in Data Adapter Configuration Wizard
Hi Cindy,
You're greater than the greatest and I'm happier than the happiest. It
solved all my problems and I can now use both Jet and VFP provider to connect
dBase files.
Thanks a lot,
Rakesh
"Cindy Winegarden" wrote:
> Hi Rakesh,
>
> 1. As I said below, "The FoxPro and Visual FoxPro OLE DB data provider will
> work correctly with all Fox tables."
>
> 2. As I said below, "Since you're using FPD 2.6 tables your OLE DB
> connection string should point to the directory where the tables are. Then
> you can use code like this: ....."Provider=VFPOLEDB.1;Data
> Source=C:\Temp\;")". DO NOT use the table name in the connection string.
> Only point to the directory. The place to specify the table name in a Select
> statement like: "("Select * From TestDBF", cn)" This is so you can use one
> connection string to access all of the Fox tables in that directory.
>
> The Jet ODBC driver works with a whole bunch of different types of tables.
> Thus you need to specify the type of table (dBase IV, Excel) using the
> Extended Properties clause. If you're working with the VFPOLEDB data
> provider then you are not working with Jet. You do not use the same type of
> connection string; for example, you don't use the Extended Properties
> clause. The VFPOLEDB data provider already knows it's working with some
> version of FoxPro DBF, and it's built to figure out which version of DBF and
> go from there.
>
> I'm not all that familiar with Jet connection strings for Excel. For your
> Excel example I see you've specified "Extended Properties=Excel 3.0;". Excel
> from Office 2003 is Excel 11 so that means Excel 3 is pretty old. Perhaps
> your tables were created with a more recent version of Excel.
>
>
> --
> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> cindy_winegarden@msn.com www.cindywinegarden.com
>
>
> "Rakesh Parekh" wrote in message
> news:DE77E1F7-0DE5-4109-8B86-EE7B5605695F@microsoft.com...
> > Dear Cindy,
> >
> > Thank you for quick response. Ok I now understand that I don't have to use
> > ODBC. I have a few questions.
> >
> > 1) Is the Provider "VFPOLEDB" common for DOS BASE applicaiton FoxPro 2.6
> > and
> > Visual Fox Pro? Is there a separate provider for FoxPro 2.6?
> >
> > 2) On MSDN help "Opening a Database" I could find that it is possible to
> > connect
> > external database using suitable Extended Properties as under:
> >
> > MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=c:\BOOKING.DBF;Extended Properties=dBASE IV;")
> >
> > I get an error as below with above Myconnection code
> >
> > 'c:\BOOKING.DBF' is not a valid path. Make sure that the path name is
> > spelled
> > correctly and that you are connected to the server on which the file
> > resides.
> >
> > What could be wrong? The path is absolutely correct. I also put the path
> > on
> > the
> > like "servername\fpdb\booking.dbf" but it says the same error.
> >
> > 3) When I use Excel like
> >
> > MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=c:\BOOKING.XLS;Extended Properties=Excel 3.0;")
> >
> > I get error as under:
> >
> > External table is not in the expected format.
> >
> > Please advise.
> > Thank you,
> > Rakesh
> >
> > "Cindy Winegarden" wrote:
> >
> >> Hi Rakesh,
> >>
> >> Since you're working in a .NET language it's time to get away from ODBC,
> >> which is a deprecated data access technology. The FoxPro and Visual
> >> FoxPro
> >> OLE DB data provider will work correctly with all Fox tables. Since
> >> you're
> >> using FPD 2.6 tables your connection string should point to the directory
> >> where the tables are. Then you can use code like this:
> >>
> >> '-- -------------------------------------------
> >> Imports System
> >> Imports System.Data
> >> Imports System.Data.OleDb
> >>
> >> Module Module1
> >>
> >> Sub Main()
> >>
> >> Dim cn As New OleDbConnection( _
> >> "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
> >> cn.Open()
> >>
> >> Dim cmd1 As New OleDbCommand( _
> >> "Create Table TestDBF (Field1 C(10))", cn)
> >> Dim cmd2 As New OleDbCommand( _
> >> "Insert Into TestDBF Values ('Hello')", cn)
> >> Dim cmd3 As New OleDbCommand( _
> >> "Insert Into TestDBF Values ('World')", cn)
> >> cmd1.ExecuteNonQuery()
> >> cmd2.ExecuteNonQuery()
> >> cmd3.ExecuteNonQuery()
> >> Dim cmd4 As New OleDbCommand("Select * From TestDBF", cn)
> >> Dim r1 As OleDbDataReader = cmd4.ExecuteReader()
> >> Dim Field1Data As String = ""
> >> While r1.Read()
> >> Field1Data += r1.GetString(0) + vbCrLf
> >> End While
> >>
> >> MsgBox(Field1Data.ToString())
> >>
> >> r1.Close()
> >> cn.Close()
> >>
> >> End Sub
> >>
> >> End Module
> >> '-- -------------------------------------------
>
>
>
>
date: Tue, 18 Apr 2006 04:21:02 -0700
author: Rakesh Parekh
|
|