Click to See Complete Forum and Search --> : create a new database in VB .NET how?
proKrastinate
December 14th, 2002, 11:28 PM
how do you create a 'new' database with only code in vb .net. I can connect to an existing database and fill a datagrid with its contents. Is it much different than that? I am assuming that after creation is when you would need to add more rows etc.
Or how about this, since the databases are going to be almost virtually the same, is there a way to copy a database with code and than erase not the rows or columns but just the data in the cells themselves?
Jym
December 15th, 2002, 09:38 AM
cat = New ADOX.Catalog()
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & file_name & ";")
'then add your tables as needed
dim tbl as new adox.table
tbl.name ="table_name"
'add your columns as needed
tbl.Columns.Append("column_name", ADODB.DataTypeEnum.adSingle)
'append your catalog (dimmed as cat) to add the new table (dimmed as tbl)
cat.Tables.Append(tbl)
'to add more tables start with "dim tbl as new adox.table"
proKrastinate
December 15th, 2002, 11:17 AM
thankx for getting me on the right track. I figured out that I needed to add a reference to ADOX and do an imports statement to use your code. Thx again
proKrastinate
December 15th, 2002, 11:18 AM
one other thing, is it necessary to add this to the end of the oCat.Create
"Jet OLEDB:Engine Type=5")
what does it do?
Jym
December 15th, 2002, 12:02 PM
I use the code exactly how I showed it to you
proKrastinate
December 15th, 2002, 10:16 PM
mine wouldn't work that way. It kept saying that adox.catalog was unidentified. but now that i did what was posted above, it seems to work without errors. Haven't tested it yet because my program is still sorting out some stuff before i can check to see whether it creates the db or not.
Jym
December 15th, 2002, 11:35 PM
did you add adox to your project ?
proKrastinate
December 16th, 2002, 12:32 AM
do you mean with an imports statement? if so, than yes, but it would only be recognized after i made the reference. before it would only recognize 'Microsoft' 'System' and "i think the name of my proj' to the imports available list that automatically comes up when you type Imports. after addding the reference the ADOX was able to be imported.
Don't know if this matters but im using only vb .net and not the entire visual studio .net.
Jym
December 16th, 2002, 07:28 AM
Yes in your solutions explorer under references you need to see BOTH adodb and adox
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.