How to create a new database on SQL Server 2000 from (VS.NET2003 C#) code

Hi

I need to include in my Visual Studio .NET 2003 project some code responsible to create a new database on a SQL Server.
Suppose I have any necessary security permission for login on SQL Server (sysadmin, serveradmin, etc.).
Note that I only use C# source in my project.

Tryed already:
1. to use SQLConnection or SQLCommand, but both require an existing database name
2. to use SQL-DBO classes, but found no support for C#

Thank you

[490 byte] By [SorinSolescu] at [2007-12-16]
# 1

Hi,

Just make a connection to the master database of a SqlServer. This database is default to every instance of SqlServer so you don't have to worry on checking. After, connecting just execute a t-sql CREATE DATABASE commands to create a database using a SqlCommand...

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2

Thanks a lot Paul !
It is just what I needed.

Sorin

SorinSolescu at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified