Click here to Skip to main content
13,903,445 members
Click here to Skip to main content
Add your own
alternative version


30 bookmarked
Posted 27 Oct 2007

Create SQL Server Database using

, 27 Oct 2007
Rate this:
Please Sign up or sign in to vote.
Here I am showing, How to Create SQL Database and Run SQL Script File Using

Fill SQL Server Authentication Information

Screenshot - Server_Settings.jpg

SQL Script File Path

Screenshot - SQL_Script_Path.jpg


To create SQL Database using is quite difficult, Here I am writing
how to create SQL Database and how to Run the SQL Script File using
To Run this Database Creation wizard, you have to Enter the Required input
and finally you will get Database created.

Here you can see two Screenshot. The first one is showing the SQL Server
Configuration that includes the ( SQL Server Name, Database Name,
SQL User ID and SQL Server Password).

And Second screen is showing the Virtual Path of SQL Script file.


Web Based SQL Database Creation Wizard is looking Odd Requirements.
But Currently I am developing one Web Application, and my Requirement
was to Create New SQL Database and run the SQL Script File that
includes Tables, View and Stored Procedures. After Database Creation,
I have to work with that Database. So I found a lot of internet,
but I didn't find any good article or resources for this, so finally
I have created this Wizard application for those who had the same
requirements like this.

Using the code

First of all you required following namespace.

Imports Microsoft.SqlServer
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common.ConnectionManager

And with the help of Classes, I have Created one DatabaseCreator.vb Class,
that contains the methods to Create SQL Database and Execute SQL Script Files.

To Create SQL Database, you have to Create the object of this class and
call required methods.

Dim objDBCreate as New DatabaseCreator
And call CreateSQLDb() Function with required Paramters, This function will
return true , if database will successfully created, otherwise it will return False.

objDBCreate.CreateSQLDb("SqlServerName", "DBName", "SQLUserID", "SQLPWD")

now after Create Database, on Next Step, we Execute the SQL Script File
by calling this Method: ExecuteSQLScript()

it takes two parameters, One is SQL Script File Path, and the Path
Should be Physical path, so you can get path using
Dim sqlpath As String = Server.MapPath("Virtual Path of SQL Script")And Second one is Connection String of Newly Created database.

Here check out little bit code. To Get full souce of Code, please download from Top link.

//This Code will create SQL Db 
//create the database procedure goes here.

objDBCreate = New DatabaseCreator
If objDBCreate.CreateSQLDb(txtServer.Text, txtDBName.Text, txtUserID.Text, _
    txtPassword.Text) = True Then
    ViewState.Add("ConStr", ConnStr)
    Return True
    Return False
End If

// This Code will Run the SQL Script File

Dim sqlpath As String = Server.MapPath(txtSQLPath.Text)
objDBCreate = New DatabaseCreator
If objDBCreate.ExecuteSQLScript(sqlpath, StrCon) Then
  CreateMessageAlert(Me.Page, "SQL Script Execute Successfully..", "Run")
  CreateMessageAlert(Me.Page, "There is an error into script file", "notrun")
End If


Now, hope you get code to create SQLDB using DatabaseCreator.vb Class.


So this way you can Create SQL database using, Please feel free to post your comments or messages for any query or further information. :)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jatin Prajapati
Team Leader
India India
Jatin is Working in .Net Technology Since 2006. He has Completed Master of Science Degree in Information Technology. He Likes to learn Cutting edge technologies. He has good Skills in,,C#.Net, Crystal Reports,GDI+, Ajax, WCF, Silverlight SQL Server,IIS Admin,TFA ,Application Architecture Designing.

You may also be interested in...


Comments and Discussions

QuestionKeep SQL user ID and SQL password and SQL server name for String connections Pin
Member 1306783418-Mar-17 17:06
memberMember 1306783418-Mar-17 17:06 
QuestionNot Working Pin
Er_Vishal7-Apr-15 4:10
memberEr_Vishal7-Apr-15 4:10 
QuestionTHANKS Pin
ANJYR25-Aug-12 2:14
memberANJYR25-Aug-12 2:14 
AnswerRe: THANKS Pin
ss9o9o9o13-Jun-13 7:46
groupss9o9o9o13-Jun-13 7:46 
QuestionHi Jatin, [modified] Pin
Nitin J. Jain7-Oct-09 1:56
professionalNitin J. Jain7-Oct-09 1:56 
GeneralConnection string Pin
BijayBhasker20-Sep-09 19:41
memberBijayBhasker20-Sep-09 19:41 
Questionwould appreciate help Pin
ts11120814-Nov-08 4:52
memberts11120814-Nov-08 4:52 
GeneralNice code Pin
srinivassnv25-Sep-08 23:24
membersrinivassnv25-Sep-08 23:24 
GeneralRe: Nice code Pin
Jatin Prajapati26-Sep-08 2:31
memberJatin Prajapati26-Sep-08 2:31 
GeneralOH! realy perfect code Pin
prokurs22-Sep-08 3:55
memberprokurs22-Sep-08 3:55 
GeneralRe: OH! realy perfect code Pin
Jatin Prajapati23-Sep-08 3:34
memberJatin Prajapati23-Sep-08 3:34 
QuestionQuestion on Web based My Sql DB Creation wizard Pin
emilng8421-Sep-08 20:06
memberemilng8421-Sep-08 20:06 
AnswerRe: Question on Web based My Sql DB Creation wizard Pin
Jatin Prajapati23-Sep-08 3:35
memberJatin Prajapati23-Sep-08 3:35 
GeneralExcellent app Pin
Razi Syed1-Nov-07 12:16
memberRazi Syed1-Nov-07 12:16 
GeneralRe: Excellent app Pin
Jatin Prajapati2-Nov-07 2:37
memberJatin Prajapati2-Nov-07 2:37 
GeneralInteresting Quick Read Pin
Paul Conrad27-Oct-07 8:58
professionalPaul Conrad27-Oct-07 8:58 
GeneralRe: Interesting Quick Read Pin
Jatin Prajapati27-Oct-07 17:33
memberJatin Prajapati27-Oct-07 17:33 
GeneralRe: Interesting Quick Read Pin
Paul Conrad27-Oct-07 19:03
professionalPaul Conrad27-Oct-07 19:03 
Questionwhat if I dont have SMO Pin
ozkan.pakdil27-Oct-07 6:35
memberozkan.pakdil27-Oct-07 6:35 
AnswerRe: what if I dont have SMO Pin
Jatin Prajapati27-Oct-07 6:40
memberJatin Prajapati27-Oct-07 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190306.1 | Last Updated 27 Oct 2007
Article Copyright 2007 by Jatin Prajapati
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid