if exists (select * from sysdatabases where name='mytest') drop database mytest GO
create database mytest GO
use mytest GO 注:其中“mytest”是要创建的数据库名。
而程序的代码如下: //---------------------------Create DB------------------------------------- //------------------------------------------------------------------------- //---File:frmCreateDB.cs //---Description:The main form file to create database using specific SQL file //---Author:Knight //---Date:Mar.18, 2006 //------------------------------------------------------------------------- //-------------------------{ Create DB }----------------------------------- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.SqlClient;