C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

Creating Database Using VB.Net


Posted Date: 04 Oct 2008    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: AbbasMember Level: Gold    
Rating: 1 out of 5Points: 7



This Code Snippet will display how to create database in SQL SERVER using VB.Net
Before Using this Application or Snippet Make Sure you Have:
1. Active SQL SERVER Connection

Imports System.Data.SqlClient Namespace

Dim connectionString As New SqlConnection("server=.;uid=sa;pwd='';database=")
Private Sub CreateDatabase(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim com As New SqlCommand("create database " + TextBox1.Text, connectionString)
cons.Open()
com.ExecuteNonQuery()
Label1.Text = "Database Created"
cons.Close()
Catch ex As Exception
Label1.Text = TextBox1.Text + " Database Already Exists"
End Try

End Sub

Private Sub DropDatabase(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim com As New SqlCommand("drop database " + TextBox1.Text, connectionString)
cons.Open()
com.ExecuteNonQuery()
Label1.Text = "Database Dropped"
cons.Close()
Catch ex As Exception
Label1.Text = TextBox1.Text + " Database Does Not Exists"
End Try
End Sub


For Further Reference Download the Sample Application Below.

By Abbas Electricwala

Attachments

  • Download Sample Application (21662-4155-Create Database And Tables.rar)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Create Database in SQL SERVER using VB.Net  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: FormatDateTime function in VB.NET
    Previous Resource: Minimizing all the forms and windows(Show Desktop)
    Return to Discussion Resource Index
    Post New Resource
    Category: VB.NET Syntax


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use