简体   繁体   English

C# WPF Access 2000-2003 文件创建

[英]C# WPF Access 2000-2003 Files Creation

How can I create access 2000-2003 file using C# WPF and add tables in, data in and perform queries on it?如何使用 C# WPF 创建 access 2000-2003 文件并在其中添加表、数据并对其执行查询?

I`m using MS Visual Studio 2010我正在使用 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.Exists(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#.以下是如何使用 c# 以编程方式创建访问数据库的示例。 I found it by saerching for "programmatically create access database c#" using google.我通过使用谷歌搜索“以编程方式创建访问数据库 c#”找到它。 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.谷歌是你的朋友,我会在未来推荐它,如果你找不到你需要的东西,你应该先使用它并在这里发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM