SIMIN Posted March 15, 2008 Posted March 15, 2008 Hi, I wanna create an access database programmatically. How should this be done? Do you recommend that I do it via code? I don't know how to create an access 2003 compatible file at run-time! Please help me:) Quote
SIMIN Posted March 16, 2008 Author Posted March 16, 2008 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 don't know how is this possible? Quote
Administrators PlausiblyDamp Posted March 16, 2008 Administrators Posted March 16, 2008 Could you not simply include the .mdb file in your installer? Failing that you could include it as an embedded resource and extract it on first run etc. http://www.xtremedotnettalk.com/showthread.php?t=83574 should get you started with using embedded resources. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SIMIN Posted March 16, 2008 Author Posted March 16, 2008 (edited) Thanks. Am I doing it right? 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 ! Edited March 16, 2008 by SIMIN Quote
Administrators PlausiblyDamp Posted March 16, 2008 Administrators Posted March 16, 2008 Use a BinaryReader rather than a StreamReader. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
FZelle Posted March 24, 2008 Posted March 24, 2008 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: object ADOXCat = Activator.CreateInstance(Type.GetTypeFromProgID("ADOX.Catalog")); ADOXCat.GetType().InvokeMember("Create", System.Reflection.BindingFlags.InvokeMethod, null, ADOXCat, new string[] { ConnectionString }); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.