異世界


顯示具有 MS Access 標籤的文章。 顯示所有文章
顯示具有 MS Access 標籤的文章。 顯示所有文章

2012年7月22日 星期日

C# 如何建立MS Access 資料庫

使用ADOX在 C# 程式建構一個MS Access 資料庫,。

1. 首先加入參考

image

image

image

 

2.

using ADOX;

 

3. 加入以下Function
public static bool CreateAccessDB(string dbName)
{
try
{
Catalog cat = new Catalog();
string strCreateDB = "";

strCreateDB += "Provider=Microsoft.Jet.OLEDB.4.0;";
strCreateDB += "Data Source=" + dbName + ";";
strCreateDB += "Jet OLEDB:Engine Type=5";
cat.Create(strCreateDB);
return true;
}
catch (Exception)
{
throw;
}
}