连接到访问db时出错0x80004005

时间:2015-11-03 20:46:39

标签: c#

我是c#language

的新手

我试图Connect to Access DB via C#

但每当我尝试连接时,我都会得到0x80004005 not a valid file name

我确定数据源和文件名

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace db_access
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=‪D:\GmTool.accdb;Persist Security Info=False;";
                conn.Open();
                MessageBox.Show("Connection Succesfull");
                conn.Close();
            }catch(Exception ex)
            {
                MessageBox.Show("Error with Connection" + ex);
            }
        }
    }
}

这是我的代码

希望你能提供帮助:)

0 个答案:

没有答案