批量邮件项目需要访问数据库连接方面的帮助 [英] Bulk mail project need a help in access database connection

查看:120
本文介绍了批量邮件项目需要访问数据库连接方面的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发直接从访问数据库检索的项目邮件ID中的批量邮件项目,但是我在数据库连接方面遇到问题,请帮助我

我的代码是这样的

I am developing a bulk mail project in project mail ids retrieve directly from access database but i am facing a problem in database connection please Help me

My code in like this

{
    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();
    }
}

推荐答案

我认为您应该使用 ^ ],如前面的解决方案中所述,使用Server.MapPath方法作为accdb文件的路径.
结果字符串应类似于:
I think that you should use the connection string from Connection strings for Access 2007[^], as reported in the preceding solution, using the Server.MapPath method for the path to the accdb file.
The resulting string should be something like:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("/db.accdb") + ";Persist Security Info=False;"


您的系统上可能未安装oledb驱动程序.在这种情况下,您必须从 2007 Office System驱动程序:数据连接组件下载它. [ ^ ]并安装


It''s possible that the oledb driver is not installed on your system. In that case you must download it from 2007 Office System Driver: Data Connectivity Components[^] and install it.


使用Provider = Microsoft.ACE.OLEDB.12.0; Data
看下面的链接
http://www.connectionstrings.com/
use Provider=Microsoft.ACE.OLEDB.12.0;Data
look at following link
http://www.connectionstrings.com/


这篇关于批量邮件项目需要访问数据库连接方面的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆