Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create database and tables from vba

Author  Topic 

Lasse_carlsson
Starting Member

2 Posts

Posted - 2014-03-11 : 08:54:13
Hello,

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 tried this but it does not work :(

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)
   

- Advertisement -