[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

mdb from schema

Posted on 2004-09-26
7
Medium Priority
?
297 Views
Last Modified: 2012-08-13
I have a schema.xsd that layouts multiple tables in my strong-typed dataset. I want to save this dataset to a completely new .mdb file with some VB code. Anyone know how?
0
Comment
Question by:srcalc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Accepted Solution

by:
User111111 earned 500 total points
ID: 12155291
I'm not sure if this would work for dynamic db schemas, but it might work if you need to continually recreate a database from the same schema.

use adox to create your database based on your schema file.  you could parse the schema programatically or you could manually read it and replace the below values....

Private Sub cmdCreate_Click()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim con As ADODB.Connection

    ' Delete the database if it already exists.
    On Error Resume Next
    Kill txtDatabaseName.Text
    On Error GoTo 0

    ' Create the new database.
    Set cat = New ADOX.Catalog
    cat.Create _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & txtDatabaseName.Text & ";"

    ' Create a new table.
    Set tbl = New ADOX.Table
    tbl.Name = "TestTable"
    tbl.Columns.Append "FirstName", adVarWChar, 40
    tbl.Columns.Append "LastName", adVarWChar, 40
    tbl.Columns.Append "Birthdate", adDate
    tbl.Columns.Append "Weight", adInteger
    cat.Tables.Append tbl

    ' Connect to the database.
    Set con = cat.ActiveConnection

    ' Insert records.
    con.Execute "INSERT INTO TestTable VALUES ('Andy', " & _
        "'Able', '1 Jan 1980', '150')"
    con.Execute "INSERT INTO TestTable VALUES ('Betty', " & _
        "'Baker', #2/22/1990#, 70)"

    ' Close the database connection.
    con.Close
    Set con = Nothing
    Set tbl = Nothing
    Set cat = Nothing

    MsgBox "Done"
End Sub
0
 
LVL 4

Author Comment

by:srcalc
ID: 12155415
is that vb .net? I cant seem to find the classes that you used:

Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim con As ADODB.Connection
0
 

Expert Comment

by:User111111
ID: 12155449
add a reference to your project, Microsoft ADO Ext. 2.6 for DLL and Security or something similar if you don't have that exact version.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:srcalc
ID: 12155597
OK, is it possible to do with System.Data.OLeDB so I don't have to use a reference?
0
 

Expert Comment

by:User111111
ID: 12156276
nope, there is no current built-in way to dynamically make a new access db in vb.net
0
 
LVL 4

Author Comment

by:srcalc
ID: 12156287
ok let me fool around with that code and get back to you
0
 
LVL 4

Author Comment

by:srcalc
ID: 12229010
OK thanks for your input!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question