Access .mdb files
-
Is it possible to create a .mdb file with c# without Access being installed? I'm trying to make a program that will create its own dbase file if/when the dbase gets deleted accidently or by clicking a button. If it'a possible, any example code or places I should be looking for more info?
-
Is it possible to create a .mdb file with c# without Access being installed? I'm trying to make a program that will create its own dbase file if/when the dbase gets deleted accidently or by clicking a button. If it'a possible, any example code or places I should be looking for more info?
You would have to use interop and the Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) To do this, since MS Access sql syntax does not support "create database". IMO a better alternative is to just include a small empty database as a template, and use filecopy to create the starting database (faster, too...). If your schema is constant, you can even pre-build all empty tables and queries, saving a good deal of 'one time' code in your application. :) Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
-
Is it possible to create a .mdb file with c# without Access being installed? I'm trying to make a program that will create its own dbase file if/when the dbase gets deleted accidently or by clicking a button. If it'a possible, any example code or places I should be looking for more info?
Let me point you to "Programming OLEDB with C#" - http://www.manning.com/dotnetbooks/csharpprimer/sql\_to\_access.html
-
Let me point you to "Programming OLEDB with C#" - http://www.manning.com/dotnetbooks/csharpprimer/sql\_to\_access.html
like I said - one must use ADOX to create an access database programatically. :) Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
-
You would have to use interop and the Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) To do this, since MS Access sql syntax does not support "create database". IMO a better alternative is to just include a small empty database as a template, and use filecopy to create the starting database (faster, too...). If your schema is constant, you can even pre-build all empty tables and queries, saving a good deal of 'one time' code in your application. :) Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
Yes, after reading the other replies I think that is much easier :) . Would it be possible to include this templated .mdb file as a resource in the app? Basically what I'm after is a single .exe file as the final result as this app would be copied rather than installed, and with the technical level of my clients, a single file is the easiest option.
-
Yes, after reading the other replies I think that is much easier :) . Would it be possible to include this templated .mdb file as a resource in the app? Basically what I'm after is a single .exe file as the final result as this app would be copied rather than installed, and with the technical level of my clients, a single file is the easiest option.
I haven't tried that, but it should work. Just create a new empty file and then copy the resource bytes to it with a BinaryWriter..bytes is bytes :) Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
-
I haven't tried that, but it should work. Just create a new empty file and then copy the resource bytes to it with a BinaryWriter..bytes is bytes :) Some ideas are so stupid that only an intellectual could have thought of them - George Orwell