DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Accessing dBase IV files with .NET

  1. #1
    Ken R Guest

    Accessing dBase IV files with .NET


    Hi

    I am trying to read dBase IV files from into a DataGrid using the MS ODBC
    driver and the OLDB Connector with no success. I get an error saying that
    the OLDB Connector does not support the selected ODBC data source.

    Can I .NET use dBase files using ODBC?

    Does anyone know of an example showing code?

    Thanks for any help.

    Ken

  2. #2
    Paul Clement Guest

    Re: Accessing dBase IV files with .NET

    On 22 Sep 2002 15:21:57 -0700, "Ken R" <vb.@127.0.0.1> wrote:


    Hi

    I am trying to read dBase IV files from into a DataGrid using the MS ODBC
    driver and the OLDB Connector with no success. I get an error saying that
    the OLDB Connector does not support the selected ODBC data source.

    Can I .NET use dBase files using ODBC?

    Does anyone know of an example showing code?

    You need to use the ODBC managed provider for .NET is you are using ODBC:

    http://support.microsoft.com/default...EN-US;q310985&

    Personally I use Jet OLEDB:

    Dim sConnectionString As String

    sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=D:\My Documents\dBase;Extended Properties=dBase IV"
    Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionString)
    objConn.Open()

    Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from MydBase", objConn)

    Dim ds As New DataSet("dBaseFile")

    da.Fill(ds, "MydBase")

    Dim dt As DataTable
    dt = ds.Tables("MydBase")

    DataGrid1.SetDataBinding(ds, "MydBase")

    Dim drCurrent As DataRow
    For Each drCurrent In dt.Rows
    Console.WriteLine("{0} {1}", _
    drCurrent("Column1").ToString, _
    drCurrent("Column2").ToString)
    Next

    objConn.Close()


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  3. #3
    Ken R Guest

    Re: Accessing dBase IV files with .NET


    Hi Paul,

    Thanks for the sample code and the MSKB link. I assume this code will work
    in a web application...

    Ken

  4. #4
    Paul Clement Guest

    Re: Accessing dBase IV files with .NET

    On 23 Sep 2002 16:47:20 -0700, "Ken R" <vb.@127.0.0.1> wrote:


    Hi Paul,

    Thanks for the sample code and the MSKB link. I assume this code will work
    in a web application...

    Should work from an ASP.NET app although I believe that the code to populate an ASP.NET Grid would
    likely be different.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  5. #5
    Ken R Guest

    Re: Accessing dBase IV files with .NET


    Paul,

    >Should work from an ASP.NET app although I believe that the code to >populate

    an ASP.NET Grid would likely be different.

    I had to tweak your example, but I was able to load a dbase file from the
    local hard disk into a Datagrid. The problem I have now is that I need to
    access dbase files on a remote network drive, and none of my connection strings
    seem to work

    Here is the ASP Code that loads a local dbase IV file into a DataGrid:

    Dim sConnectString As String
    sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\Inetpub\wwwroot\WebApplication1;Extended
    Properties=dBase IV"

    Dim Conn As New OleDb.OleDbConnection(sConnectString)
    Dim Cmd As New OleDb.OleDbCommand("Select * from System", Conn)
    Conn.Open()
    DataGrid1.DataSource = Cmd.ExecuteReader (CommandBehavior.CloseConnection)
    DataGrid1.DataBind()

    Here are some failed connection strings:
    Remote drive mapped to E: on server
    sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=E:\;Extended Properties=dBase IV;User ID=WEB12;Password=1234"

    Using network share name
    sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=\\Office-12\acomm;Extended Properties=dBase IV;User ID=WEB12;Password=1234"

    Any ideas?

    Thanks

    Ken




  6. #6
    Paul Clement Guest

    Re: Accessing dBase IV files with .NET

    On 26 Sep 2002 16:23:54 -0700, "Ken R" <vb.@127.0.0.1> wrote:


    Paul,

    >Should work from an ASP.NET app although I believe that the code to >populate
    an ASP.NET Grid would likely be different.

    I had to tweak your example, but I was able to load a dbase file from the
    local hard disk into a Datagrid. The problem I have now is that I need to
    access dbase files on a remote network drive, and none of my connection strings
    seem to work

    Here is the ASP Code that loads a local dbase IV file into a DataGrid:

    Dim sConnectString As String
    sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\Inetpub\wwwroot\WebApplication1;Extended
    Properties=dBase IV"

    Dim Conn As New OleDb.OleDbConnection(sConnectString)
    Dim Cmd As New OleDb.OleDbCommand("Select * from System", Conn)
    Conn.Open()
    DataGrid1.DataSource = Cmd.ExecuteReader (CommandBehavior.CloseConnection)
    DataGrid1.DataBind()

    Here are some failed connection strings:
    Remote drive mapped to E: on server
    sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=E:\;Extended Properties=dBase IV;User ID=WEB12;Password=1234"

    Using network share name
    sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=\\Office-12\acomm;Extended Properties=dBase IV;User ID=WEB12;Password=1234"


    I used the UNC path to the folder as in your last example (with VB.NET) and I didn't have any
    problem. What is the error you are getting? If I had to guess it's either a permissions issue (are
    you using the Anonymous account) or the web server (if you're not working locally) can't see this
    resource.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  7. #7
    Ken R Guest

    Re: Accessing dBase IV files with .NET


    >What is the error you are getting? If I had to guess it's either a permissions
    >issue (are
    >you using the Anonymous account) or the web server (if you're not working

    locally)
    >can't see this
    >resource.


    The error I get with the examples above is:
    Cannot start your application. The workgroup information file is missing
    or opened exclusively by another user

    If I remove the user id and password strings I get invalid path name errors.

    On the IIS settings \\Office-12\acomm is mapped as virtual directory, and
    I am able hyperlink to an html page located on the remote drive. (after a
    logon window asks for user/pw) The remote drive is also mapped as E: on the
    server pc and I am able to read/write files with no problem.

    The remote drive is setup to allow full access to everyone, guests and admins.


    Am I missing a step to connect to the remote drive before trying to access
    the file?



    Ken R


  8. #8
    Paul Clement Guest

    Re: Accessing dBase IV files with .NET

    On 27 Sep 2002 15:05:31 -0700, "Ken R" <vb.@127.0.0.1> wrote:


    >What is the error you are getting? If I had to guess it's either a permissions
    >issue (are
    >you using the Anonymous account) or the web server (if you're not working
    locally)
    >can't see this
    >resource.

    The error I get with the examples above is:
    Cannot start your application. The workgroup information file is missing
    or opened exclusively by another user

    I don't think you can use the Jet provider if your dBase file requires a native user ID and
    password. The message indicates that it's looking for the system.mdw file which is Jet security
    (Access database). You will probably need to go back to ODBC if you are using dBase security.


    If I remove the user id and password strings I get invalid path name errors.

    I'm not sure what is going on here. It sounds like there is a configuration issue with respect to
    the web server in that it's not able to see the path to the remote machine (where your database is
    located).


    On the IIS settings \\Office-12\acomm is mapped as virtual directory, and
    I am able hyperlink to an html page located on the remote drive. (after a
    logon window asks for user/pw) The remote drive is also mapped as E: on the
    server pc and I am able to read/write files with no problem.

    The remote drive is setup to allow full access to everyone, guests and admins.


    Am I missing a step to connect to the remote drive before trying to access
    the file?

    I'm assuming your login dialog is for IIS authentication to the web page, which means you're not
    using anonymous (no) authentication. I don't know your configuration very well, but any user who
    logs in to your web server must be able to see the remote drive from the web server. This is
    probably where the problem is. You can verify it by trying to open the dBase file on the web server
    first. If that works, then you know the problem is connecting to the remote machine from the web
    server.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  9. #9
    Ken R. Guest

    Re: Accessing dBase IV files with .NET


    Paul,

    The web security settings are not right and I need to spend some learning
    time with the IIS 5 security settings, not wasting your time with non-programming
    issues.

    Thanks again for your help!

    Ken Rackowski



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center