Connecting to MSSQL without a database

  • Thread starter Thread starter no0obster
  • Start date Start date
N

no0obster

Hello,

I'm writing an application that should create a SQL Server 7 database
if it doens't exist.
i'm using the System.Data.SqlClient objects to connect and run queries.

My connection fails to the database because the database doesn't exist.

Can the connection string (ConnectionString) be legal without refering
to a database?

Actually any good reference on how to create a SQL Server application
in CSharp that creates a database by itself would be great.


Also what the appropriate newsgroups to post this question to - in case
there are more relevant ones?
 
You'll probably have to connect to the master db first, then create the db,
then change your connection string.

I haven't done this, so be careful messing with the master db.
 
You can also check out SQLDMO.dll
You can use it to create databases.You can authenticate to the server
without a database. You can use trusted security or sql security. As
long as you have access, you can create databases, stored procs,
tables, whatever.
 
When you don't have a database and need one tempdb is available to all valid
logins. To create a database you need to be in master.
 
Back
Top