开发者

C# WPF Access 2000-2003 Files Creation

开发者 https://www.devze.com 2023-01-07 07:10 出处:网络
How can I create access 2000-2003 file using C# WPF and add tables in, data in and perform queries on it?

How can I create access 2000-2003 file using C# WPF and add tables in, data in and perform queries on it?

I`m using MS Visual Studio 2010

this is what I`ve been able to accomplish:

        OleDbConnection conn = new OleDbConnection();
        string myDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        string dbPath = myDir + @"\EmpMan.mdb";
        MessageBox.Show(myDir);
        if (!File.Ex开发者_如何学Goists(dbPath))
        {
            //Here I want my program to create an Access DB File in the dbPath location...
        }
        conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + ";Password=EmpMan";
        try
        {
            conn.Open();
        }
        catch (OleDbException ex)
        {
            MessageBox.Show("Error: " + ex.Errors[0].Message);
            Application.Current.Shutdown();
        }


Here is an example of how to programatically create an access database using c#. I found it by saerching for "programmatically create access database c#" using google. Google is your friend, I would recomend in future that and you should use it first and post here if you can't find what you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消