0

我正在尝试以编程方式使用 MailMerge(来自 C#)。我使用 Access 数据库文件作为数据源。Access 数据库有密码。以下代码由于某种原因不起作用,即使它应该起作用。我得到一个无效的密码文本框。

       WordApp = new ApplicationClass();

        WordApp.Visible = true;

        adoc = WordApp.Documents.Open(ref Template,
                             ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
                             ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
                             ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);


        Object sql = "SELECT * FROM TestMergeTest";

        Object conn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + @"C:\Documents and Settings\sebastianharko.AKA-OS\Desktop\See.mdb" + ";"
             + "Jet OLDEDB:Database Password=" + @"notpassword" + ";";

        Object password = "notpassword";

        adoc.MailMerge.OpenDataSource(@"C:\Documents and Settings\sebastianharko.AKA-OS\Desktop\See.mdb", ref Missing,
              ref Missing, ref Missing, ref Missing, ref Missing,
             ref Missing, ref Missing, ref Missing, ref Missing,ref Missing, ref conn, ref sql, ref Missing, ref Missing, ref Missing);

任何帮助将不胜感激。

4

1 回答 1

0

您确定连接字符串的格式吗?这是我通过谷歌搜索 'Jet 4.0 连接字符串得到的示例:"

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=zzyzz;
于 2009-07-24T04:41:42.087 回答