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.
Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework" and then click "Visual Studio."
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:
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;"
Create the "create database" query. The following code shows you how to create a database named "customers":
query = "create database customers on primary"
Execute the query to create the database. The following code creates the database:
cmd = New SqlCommand(query, con)