开发者

create database using C#?

开发者 https://www.devze.com 2023-03-01 06:31 出处:网络
is it possible to create access database on a c:\\ drive on开发者_如何学JAVA the click event of the button ???Yes you can.But this is a duplicate.

is it possible to create access database on a c:\ drive on开发者_如何学JAVA the click event of the button ???


Yes you can. But this is a duplicate.

To create an Access database from C# code use ADOX: - How to create an Access database by using ADOX and Visual C# .NET:

using System;
using ADOX;

namespace ConsoleApplication1
{
    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {
            ADOX.CatalogClass cat = new ADOX.CatalogClass();

            cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
                   "Data Source=D:\\AccessDB\\NewMDB.mdb;" +
                   "Jet OLEDB:Engine Type=5");

            Console.WriteLine("Database Created Successfully");

            cat = null;

        }
    }
}

[To create an SQL Server database from C# code use SQL Server Management Objects (SMO).]


You could use office automation to create a new database and save it to the local drive.

Or if you have a template of a database you could use that and copy it to the local drive.

Without knowing exactly what you are trying to do, a more useful answer can't be given.

0

精彩评论

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