Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:)

Posted

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?

  • Administrators
Posted
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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (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 by SIMIN
Posted

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 });

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...