Create Access Database

SIMIN

Well-known member
Joined
Mar 10, 2008
Messages
92
Hi,
I wanna create an access database programmatically.
How should this be done?
Do you recommend that I do it via code?
I dont know how to create an access 2003 compatible file at run-time!
Please help me:)
 
Please help me,
If there is no way to do it via .NET, can I create an access 2003 mdb file manually, import it to my project resources and then extract it from my application?
The mdb file should be embedded in my main application exe file, but I dont know how is this possible?
 
Thanks.
Am I doing it right?
Code:
Dim myAssem As [Assembly]
myAssem = [Assembly].GetExecutingAssembly()
Dim s As System.IO.Stream = myAssem.GetManifestResourceStream("EmbeddedResources.Res.db")
Dim sr As New System.IO.StreamReader(s)
My.Computer.FileSystem.WriteAllText("D:\Res.db", sr.ReadToEnd(), False)
It works with text files, but not with .mdb files, even if I change the extension to .db !
 
Last edited by a moderator:
Normaly you would use ADOX for this task, but since vista there is a problem
with "just" adding that COM component, because vista has a version 6.0 of the mdac.

But you can use this to get your goal:
Code:
 object ADOXCat = Activator.CreateInstance(Type.GetTypeFromProgID("ADOX.Catalog"));
                ADOXCat.GetType().InvokeMember("Create", System.Reflection.BindingFlags.InvokeMethod, null, ADOXCat, new string[] { ConnectionString });
 
Back
Top