Best way to create a new SQL Server database
Posted: Wed 16 Mar 2011 17:46
I'm totally new at developing with MS SQL Server, so forgive my ignorance in advance. I searched the forum for an answer but didn't find anything, so hopefully there is a quick answer for me.
I have our code connecting successfully to SQL Servers and opening existing databases, but when I try to create a new database I get the following error:

I figured the easiest way to create a new database was simply by invoking the SQL command "CREATE DATABASE [databasename]", but apparently I have to have another database already selected before calling this code. Why is that, and is there any way around this limitation?
When attempting to create a new database, I simply connect to a server with the TMSConnection::Database property left blank. Based on the SDAC docs, I thought the server still connected to whatever default database is set up for the user (perhaps the "master" database)? If that's true, then why am I getting this error?
Most importantly, is there a better way to create new databases via the SDAC components?
I have our code connecting successfully to SQL Servers and opening existing databases, but when I try to create a new database I get the following error:

I figured the easiest way to create a new database was simply by invoking the SQL command "CREATE DATABASE [databasename]", but apparently I have to have another database already selected before calling this code. Why is that, and is there any way around this limitation?
When attempting to create a new database, I simply connect to a server with the TMSConnection::Database property left blank. Based on the SDAC docs, I thought the server still connected to whatever default database is set up for the user (perhaps the "master" database)? If that's true, then why am I getting this error?
Most importantly, is there a better way to create new databases via the SDAC components?