The Jet.Oledb.4.0 driver doesn't work for access 2007 (.accdb), only for Access 2003 (*.mdb) and below.
So either convert your .accdb file to an .mdb, or use the new ACE 12.0 driver. Note that this driver is NOT installed by default on a Windows server, so it might not be available in you production environment!
This is the error massiage evry time iam getting while debuging
Server Error in '/BulkEmail_test' Application.
Not a valid file name.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Not a valid file name.
Source Error:
Line 30: {
Line 31: OleDbConnection cn = new OleDbConnection(connectString);
Line 32: cn.Open(); Line 33: OleDbCommand cmd = new OleDbCommand("Select emp_email from Emails_be.laccdb", cn);
Line 34: OleDbDataReader accessemp_email = cmd.ExecuteReader();
durgaprakash
Member
120 Points
134 Posts
Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:13 PM|LINK
Iam doing bulkmail Project in this the email ids retrive from MS accsess database but i could not open the connection and my code is like this
protected void btn1_Click(object sender, EventArgs e)
{
OleDbConnection cn = new OleDbConnection(connectString);
cn.Open();
OleDbCommand cmd = new OleDbCommand("Select * from db.accdb", cn);
OleDbDataReader accessemp_email = cmd.ExecuteReader();
while (accessemp_email.Read())
{
email = accessemp_email.GetValue(i).ToString();
Email_List.Add(email);
i = i + 1 - 1;
}
accessemp_email.Close();
cn.Close();
SendMail();
}
pelease Help Me
Regards,
Prakash
Prakash
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:15 PM|LINK
I think the problem is your connectionstring, please post it so we can have a look. It should look like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myDatabase.mdb;User Id=admin;Password=;
durgaprakash
Member
120 Points
134 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:17 PM|LINK
{
ArrayList Email_List = new ArrayList();
int i = 0;
string email;
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=//db.accdb;Persist Security Info=True;";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn1_Click(object sender, EventArgs e)
{
OleDbConnection cn = new OleDbConnection(connectString);
cn.Open();
OleDbCommand cmd = new OleDbCommand("Select * from db.accdb", cn);
OleDbDataReader accessemp_email = cmd.ExecuteReader();
while (accessemp_email.Read())
{
email = accessemp_email.GetValue(i).ToString();
Email_List.Add(email);
i = i + 1 - 1;
}
accessemp_email.Close();
cn.Close();
SendMail();
}
Prakash
chiragtoad
Member
212 Points
51 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:17 PM|LINK
check this thread this may help you
http://forums.asp.net/t/1571690.aspx/1
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:27 PM|LINK
Check your conn string against these samples shown on connectionstrings.com
http://connectionstrings.com/access-2007
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:29 PM|LINK
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=//db.accdb;Persist Security Info=True;";
Umm, why are you using " + " in the middle of the connection string? It should be like this:
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=//db.accdb;Persist Security Info=True;";
hans_v
All-Star
35986 Points
6550 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:34 PM|LINK
The Jet.Oledb.4.0 driver doesn't work for access 2007 (.accdb), only for Access 2003 (*.mdb) and below.
So either convert your .accdb file to an .mdb, or use the new ACE 12.0 driver. Note that this driver is NOT installed by default on a Windows server, so it might not be available in you production environment!
http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET
durgaprakash
Member
120 Points
134 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:37 PM|LINK
Thnaks my dear thank u so much
Prakash
durgaprakash
Member
120 Points
134 Posts
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 12:51 PM|LINK
This is the error massiage evry time iam getting while debuging
Server Error in '/BulkEmail_test' Application.
Not a valid file name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Not a valid file name.
Source Error:
Line 30: { Line 31: OleDbConnection cn = new OleDbConnection(connectString); Line 32: cn.Open(); Line 33: OleDbCommand cmd = new OleDbCommand("Select emp_email from Emails_be.laccdb", cn); Line 34: OleDbDataReader accessemp_email = cmd.ExecuteReader();Prakash
bbcompent1
All-Star
32974 Points
8500 Posts
Moderator
Re: Database connection help, retreive email addresses from database, no connection.
May 01, 2012 02:05 PM|LINK
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;";