Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 07, 2012 01:55 AM by Decker Dong - MSFT
All-Star
118619 Points
18779 Posts
May 03, 2012 01:39 AM|LINK
bbcompent1 Try to make sure that your filename for the database is correct and you're using the correct path. Like this: string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.accdb;Persist Security Info=True;"; if its in the root, in the data directory: string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db.accdb;Persist Security Info=True;";
Try to make sure that your filename for the database is correct and you're using the correct path. Like this:
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.accdb;Persist Security Info=True;"; if its in the root, in the data directory:
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db.accdb;Persist Security Info=True;";
My addition——
For accdb database,I think it's better to use ACE driver instead of Oledb4.0。For connection string,you can find more at:
http://www.connectionstrings.com/access-2007
32974 Points
8500 Posts
Moderator
May 03, 2012 10:18 AM|LINK
His table name just looks off to me as well:
("Select emp_email from Emails_be.laccdb", cn);
Shouldnt that be just Emails_be?
May 03, 2012 10:19 AM|LINK
Although the best option I recommend is turn your access db into a sql db using the upsizing wizard. Then you are able to take full advantage of SQL Server, stuff like Stored Procs and such are not available in Access :)
May 07, 2012 01:55 AM|LINK
durgaprakash OleDbCommand cmd = new OleDbCommand("Select emp_email from Emails_be.laccdb", cn);
You should select from a DataTable's Name instead of a database's name at "Emails_be.laccdb"……
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 03, 2012 01:39 AM|LINK
My addition——
For accdb database,I think it's better to use ACE driver instead of Oledb4.0。For connection string,you can find more at:
http://www.connectionstrings.com/access-2007
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Database connection help, retreive email addresses from database, no connection.
May 03, 2012 10:18 AM|LINK
His table name just looks off to me as well:
("Select emp_email from Emails_be.laccdb", cn);Shouldnt that be just Emails_be?
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Database connection help, retreive email addresses from database, no connection.
May 03, 2012 10:19 AM|LINK
Although the best option I recommend is turn your access db into a sql db using the upsizing wizard. Then you are able to take full advantage of SQL Server, stuff like Stored Procs and such are not available in Access :)
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 07, 2012 01:55 AM|LINK
You should select from a DataTable's Name instead of a database's name at "Emails_be.laccdb"……