is it possible to create access database on a c:\ drive on the click event of the button ???
-
Create from scratch? Or from an existing one? What exactly are you trying to achieve?Oded– Oded2011-04-29 06:17:54 +00:00Commented Apr 29, 2011 at 6:17
-
possible duplicate of How do I create a Microsoft Jet (Access) database without an interop assembly?Mitch Wheat– Mitch Wheat2011-04-29 06:23:57 +00:00Commented Apr 29, 2011 at 6:23
-
Depends on where on the C: drive. In the root, you'd likely not be able to because of restrictions on write permissions.David-W-Fenton– David-W-Fenton2011-04-30 19:39:46 +00:00Commented Apr 30, 2011 at 19:39
Add a comment
|
2 Answers
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).]
1 Comment
Oded
He is looking to create an access database, not SQL Server.
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.
1 Comment
David-W-Fenton
Why would anybody use automation to create it when you've got Jet available on every copy of Windows since 2000? +1 for the template, though.