Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA SQL Create database and table

Status
Not open for further replies.

Per9922

IS-IT--Management
Oct 1, 2004
74
SE
Hello all,

I really need the help from you! I would like to do the following from a VBA script:

1) Create an SQL database with UID=User and PWD=Password
2) Include a table in the database

I have serached the forum but I can not find anything

Please help!

Per
 
Yes, but I can not find any good example....

This does not work, how to create the connection string ? How to create the tables ?

Dim str
Dim conn, rst
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=MSDASQL;DSN=WINCC;UID=;PWD;"
conn.CursorLocation = 3
conn.Open

str = "CREATE DATABASE MyDatabase1"
Set rst = conn.Execute(str)
 
There is a good reference on connection strings.

You should first test the connection with an existing database and table on the server to make sure you can at least connect. Then you add creating a database. And then once these have all been executed successfully you attempt to create a table. Baby steps.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top