943,875 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 678
  • VB.NET RSS
Jul 4th, 2009
0

how to create database

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
sweetsasthi is offline Offline
26 posts
since Jun 2009
Jul 5th, 2009
0

Re: how to create database

sweetsasthi,

General Syntax:
Create database databasename.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 6th, 2009
0

Re: how to create database

Thank you.
But can I have the exact coding for creating a database when a button is clicked in vb.net
Reputation Points: 10
Solved Threads: 0
Light Poster
sweetsasthi is offline Offline
26 posts
since Jun 2009
Jul 6th, 2009
0

Re: how to create database

VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 22
Solved Threads: 9
Junior Poster
Piya27 is offline Offline
112 posts
since Jun 2009
Jul 6th, 2009
0

Re: how to create database

similarly try for Deleting the Database....
Reputation Points: 22
Solved Threads: 9
Junior Poster
Piya27 is offline Offline
112 posts
since Jun 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: DBdataset Dynamic file path
Next Thread in VB.NET Forum Timeline: Parse an xml stream





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC