• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 373
  • Last Modified:

Connecting to NorthWind Access Database?

I am trying to connect to an Access Database to do some testing, I have the following:

public System.Data.DataSet GetAuthorData(string lcID)
    {
        if (lcID == "")
            lcID = "%";

        DataSet ds = new DataSet();
       //create the database connection
        OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Northwind 2007.accdb");
        OleDbDataAdapter oAdapter = new OleDbDataAdapter();
        //create the command object and store the sql query
        OleDbCommand aCommand = new OleDbCommand("select * from Customer List where ID like '" + lcID + "%'", aConnection);
        try
        {
            aConnection.Open();

            //create the datareader object to connect to table
            OleDbDataReader aReader = aCommand.ExecuteReader();
            Console.WriteLine("This is the returned data from emp_test table");


            oAdapter.SelectCommand = aCommand;
            oAdapter.Fill(ds, "Authors");


            //close the reader
            aReader.Close();

            //close the connection Its important.
            aConnection.Close();
        }

        //Some usual exception handling
        catch(OleDbException e)
        {
            return null;
        }

        return ds;
    }


@  aConnection.Open();

An exception is thrown and the result is null. So I believe the connection is the issue:

        OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Northwind 2007.accdb");

Any ideas on what may be wrong with the connection?
0
directxBOB
Asked:
directxBOB
  • 2
1 Solution
 
Gautham JanardhanCommented:
what sort of exception
0
 
digitalZoCommented:
 OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Northwind2007.accdb");

There should be no space.
0
 
directxBOBAuthor Commented:
base {System.Data.Common.DbException} = {"Could not find installable ISAM."}
0
 
Gautham JanardhanCommented:
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now