how to create a database using adodb in vb.net?

Posted by Sharmilaponraj under VB.NET on 3/21/2012 | Points: 10 | Views : 2056 | Status : [Member] | Replies : 5
what r all the files needed to install vb.net to create database using adodb, sql & oledb?

Thanks&Regards
Sharmila



Responses

Posted by: Vuyiswamb on: 3/21/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Why do you want to create a dataase from Code? is there a specific reason ?

Thank you for posting at Dotnetfunda
[Administrator]

Sharmilaponraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sharmilaponraj on: 3/21/2012 [Member] Starter | Points: 25

Up
0
Down
is thr anyother method to create a database without using codes?


Thanks&Regards
Sharmila

Sharmilaponraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/21/2012 [Member] Bronze | Points: 25

Up
0
Down
Sharmilaponraj

Use This Link
http://www.dreamincode.net/forums/topic/74114-a-really-simple-database/


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sharmilaponraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/21/2012 [Member] Bronze | Points: 25

Up
0
Down

Put One Button

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />




Write Ur Code in Onclick

Protected Sub Button1_Click(sender As Object, e As EventArgs)

Dim con As New SqlConnection("UrConnectionString")
con.Open()
Dim cmd As New SqlCommand("Create Database Dabasename ")
cmd.CommandType = CommandType.Text

cmd.ExecuteNonQuery()
con.close()
End Sub





Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sharmilaponraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/21/2012 [Member] Bronze | Points: 25

Up
0
Down
TO Sharmilaponraj


PUt Two Button

One for Create
    <asp:Button ID="Button1" runat="server" Text="CreateDatabase" 

onclick="Button1_Click" />


Another For Drop
asp:Button ID="Button2" runat="server" onclick="Button2_Click" 

Text="DropDatabase" />


Code Behind


P
rotected Sub Button1_Click(sender As Object, e As EventArgs)

Dim Cons As String = "Data Source=OMNEX110\SQL2K5;Initial Catalog=Test_SP1;User ID=sa;Password=omnex"

Using Con As New SqlConnection(Cons)
Using Cmd As SqlCommand = Con.CreateCommand()
Cmd.CommandText = "Create Database Databasename"

Con.Open()
Cmd.ExecuteNonQuery()
Con.Close()
End Using
End Using
End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs)

Dim Cons1 As String = "Data Source=OMNEX110\SQL2K5;Initial Catalog=Test_SP1;User ID=sa;Password=omnex"

Using Con1 As New SqlConnection(Cons1)
Using Cmd1 As SqlCommand = Con1.CreateCommand()
Cmd1.CommandText = "Drop Database Databasename"

Con1.Open()
Cmd1.ExecuteNonQuery()
Con1.Close()
End Using
End Using
End Sub



NOw Check Ur Database....

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sharmilaponraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response