General discussion

Locked

SQL Server, Database Creation using VB.NET Code

By madni.abbasi ·
Hello,

I think my question is very silly but i expect some solution 'll be there. I wanted to create database on SQL SERVER using VB.NET Code and also tables,stored procedures etc. is there any way to do like this or is there any way to create db and transfer some data ?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Check out these

by onbliss In reply to SQL Server, Database Crea ...

http://www.c-sharpcorner.com/Code/2002/Mar/CreatingDBProgrammaticallyMCB.asp
http://www.codeproject.com/cs/database/CreateDB.asp
http://davidhayden.com/blog/dave/archive/2006/01/27/2775.aspx (for SQL Server 2005 with SMO)

The above are C# examples that will give you an idea on to do the same in VB.net

Collapse -

Dynamic Database creation in SQL or Mysql

by rathinam In reply to SQL Server, Database Crea ...

///This example shows for Mysql database

/// First the establish the connection in usual manner as follows

Dim Con
Dim Sql
Dim cmd As New MySqlCommand
Sql = "Database=Dbase;server=localhost;User Id=root;Pwd=password"
Try
Con = New MySqlConnection(Sql)
If Con.State = ConnectionState.Closed Then
Con.Open()

///connection is opened successfully Then ?..

/// use your normal SQL commands as you use in your SQL Prompt ?
In the following sql string >>>>

Sql = "CREATE DATABASE IF NOT EXISTS d1base; " & _
"USE d1base; " & _
"DROP TABLE IF EXISTS branch_mast; " & _
"CREATE TABLE branch_mast(" & _
"Br_Code varchar(5) default NULL," & _
"Br_Name varchar(25) default NULL" & _
") ENGINE=InnoDB DEFAULT CHARSET=latin1 ; "

////Run the command CMD here your SQL STATEMENTS or the commands will be executed. >>>>

cmd = New MySqlCommand(Sql, gencon)
cmd.ExecuteNonQuery()

End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try


End Sub

GOOD LUCK !!!!!

B. Rathina Kumar
(rathinam@vsnl.net)

Collapse -

CHECK THIS

by sosti In reply to SQL Server, Database Crea ...

http://www.vbdotnetheaven.com/UploadFile/mahesh/CreateSQLDatabase04252005064419AM/CreateSQLDatabase.aspx

POSTED:safi malete

Back to Networks Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums