Create sql database from vba

Hello,

I would like to create a database and add tables from VBA. Can someone help me ? I have tried the following code with no sucess :(

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)

1 answer

What error message are you getting when you run that?