Connecting to MSSQL without a database

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?
 
S

sloan

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.
 
S

Steven Nagy

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.
 
N

newscorrespondent

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top