"CREATE DATABASE" withOUT ADOX (SQL)

Enigmachrysalis

Active Member
Joined
Apr 13, 2009
Messages
350
The following all is set to occur in Excel VBA (i.e. why it's not in Access forum)

I know of a way to create a database using a new ADOX catalog, BUT as there is a dedicated "CREATE DATABASE db_Name" SQL statement., I was wondering how you can execute a SQL statement (as you would to create a table) when there is no file to which you can connect yet.

I have searched for some manner of execute statement in ADOX, but all I can find is Create in the ADOX library.

P.S. I tried to connect to the prospective save folder location, but the error prompt indicates that the location is in use or it cannot be accessed.
 
This is probably a stupid question but why don't you want to use ADO(X) or other methods?

I've used DAO/ADO/Oracle/MySQL, probably a few other database technologies, programming languages etc

I've never heard of anything that would create tables/whatever without using some sort of code involving that sort of thing.

And I also think that you might be taking the wrong route - take advantage of the in-built functionality that's available.

Don't try and re-invent the wheel.:)
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You can create tables using SQL but it wouldn't be a simple 3 word statement.

Here's an example:

CREATE TABLE Top500Imported (F1 VARCHAR(50), F2 VARCHAR(50), F3 VARCHAR(50), F4 VARCHAR(50), F5 VARCHAR(50), F6 VARCHAR(50), F7 VARCHAR(50), F8 INT, F9 INT);

To use this you would create a new query, don't add any tables/fields to it.

Then in design view goto View>SQL, paste the above into the SQL window and then hit Run (!).

Is that what you are looking for?
 
Upvote 0
No, that quote I re-posted was in response to the question before it earlier in the post that I thought you must not have seen.

I know how to create the tables with SQL, but I wondered if there was a way to do the same with the CREATE DATABASE stmt.
 
Upvote 0
Sorry I'm confused, and I apologise for not reading the previous posts.

There is a CREATE DATABASE as you seem to know but I think that's all it does - create the database.

You then need to use CREATE TABLE with the database you've created to create the tables.

There is no one-liner for creating a database and tables in the database in one go.

You could probably use some sort of stored procedure, but that wouldn't be one-line either.:)
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,030
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top