how to create database

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jun 2009
Posts: 23
Reputation: sweetsasthi is an unknown quantity at this point 
Solved Threads: 0
sweetsasthi sweetsasthi is offline Offline
Newbie Poster

how to create database

 
0
  #1
Jul 4th, 2009
hai friends,
I dont know how to create database dynamically in vb.net.(if a button is clicked 4 databases in access or sql has to be created).similarly by clicking the delete button the specified database should be deleted.can you help me out with the coding.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,428
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 434
adatapost's Avatar
adatapost adatapost is online now Online
Nearly a Posting Maven

Re: how to create database

 
0
  #2
Jul 5th, 2009
sweetsasthi,

General Syntax:
Create database databasename.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 23
Reputation: sweetsasthi is an unknown quantity at this point 
Solved Threads: 0
sweetsasthi sweetsasthi is offline Offline
Newbie Poster

Re: how to create database

 
0
  #3
Jul 6th, 2009
Thank you.
But can I have the exact coding for creating a database when a button is clicked in vb.net
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 105
Reputation: Piya27 is an unknown quantity at this point 
Solved Threads: 8
Piya27's Avatar
Piya27 Piya27 is offline Offline
Junior Poster

Re: how to create database

 
0
  #4
Jul 6th, 2009
  1. [code = VB.NET]
  2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.  
  4. Dim con As SqlConnection
  5. Dim sql As String
  6. Dim cmd As SqlCommand
  7.  
  8. con = New SqlConnection("Server=urserver;" & "DataBase=;" & "Integrated Security=ur security;")
  9. sql = "CREATE DATABASE ABC ON PRIMARY" + "(Name=abc_data, filename = 'C:\MSSQL7\data\abc.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=abc_log, filename='C:\MSSQL7\abc_log.ldf',size=3," + "maxsize=20,filegrowth=1)"
  10. con.Open()
  11.  
  12. cmd = New SqlCommand(sql, con)
  13.  
  14. Try
  15. cmd.ExecuteNonQuery()
  16. MsgBox("DATABASE Created")
  17. Catch ex As Exception
  18. MsgBox("Database Already Exists!")
  19. End Try
  20.  
  21. End Sub
Regards,
Piya:)
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 105
Reputation: Piya27 is an unknown quantity at this point 
Solved Threads: 8
Piya27's Avatar
Piya27 Piya27 is offline Offline
Junior Poster

Re: how to create database

 
0
  #5
Jul 6th, 2009
similarly try for Deleting the Database....
Regards,
Piya:)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC