How to Create a Database in VB.Net

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

The VB.NET programming language contains functions and libraries that let you manipulate databases. You can query the database, but you can also create a new database on the server. This code is beneficial for programmers who create database applications for internal employees or database administrator clients.

Skill level:

Other People Are Reading


  1. 1

    Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework" and then click "Visual Studio."

  2. 2

    Right-click the VB.NET file you want to use to create the database. Click "View Code." At the top of the opened file, copy and paste the following library files needed to create the database:

    Import System.Net.SQLClient

    Import System.Net.Data

  3. 3

    Create the connection string. The connection string contains all drivers and properties needed to connect to the server. Use the following code to connect to a local SQL Server:

    conn.ConnectionString = "Integrated Security=SSPI;Initial Catalog=mydb;Data Source=localhost;"

  4. 4

    Create the "create database" query. The following code shows you how to create a database named "customers":

    query = "create database customers on primary"

  5. 5

    Execute the query to create the database. The following code creates the database:

    cmd = New SqlCommand(query, con)

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.