We help IT Professionals succeed at work.

Connecting to NorthWind Access Database?

directxBOB
directxBOB asked
on
396 Views
Last Modified: 2012-05-05
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?
Comment
Watch Question

CERTIFIED EXPERT

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

There should be no space.

Author

Commented:
base {System.Data.Common.DbException} = {"Could not find installable ISAM."}
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.