如何使用 C# WPF 创建 access 2000-2003 文件并在其中添加表、数据并对其执行查询?
我正在使用 MS Visual Studio 2010
这是我能够完成的:
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();
}