Link to home
Start Free TrialLog in
Avatar of directxBOB
directxBOBFlag for Ireland

asked on

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?
Avatar of Gautham Janardhan
Gautham Janardhan

what sort of exception
 OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Northwind2007.accdb");

There should be no space.
Avatar of directxBOB

ASKER

base {System.Data.Common.DbException} = {"Could not find installable ISAM."}
ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial