Use SqlCommand.ExecuteNonQuery
Imports System.Data.SqlClient
Dim queryString As String = "CREATE DATABASE [0105] ON PRIMARY (NAME = N'0105', FILENAME = N'C:\APPDATA\Pluto_Data.MDF' , SIZE = 1024KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) " & _
"LOG ON (NAME = N'0105_Log', FILENAME = N'C:\APPDATA\0105_Log.LDF' , SIZE = 1024KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )"
Using connection As New SqlConnection(queryString)
Dim command As New SqlCommand(queryString, connection)
command.Connection.Open()
command.ExecuteNonQuery()
End Using
Just change the bits you need to change above like the filegroup, file growth and initial sizes etc. I think that'll work although I haven't got LocalDB to hand to try it so I may be a bit off course.
EDIT: I was off course and too free and easy with the T-SQL.
Try this instead, from the link I added in a comment below.
Public Function CreateDatabase(ByVal dbName As String, ByVal dbFileName As String) As Boolean
Try
Dim connectionString As String = String.Format("Data Source=(LocalDB)\v11.0;Initial Catalog=master;Integrated Security=True")
Using connection As New SqlConnection(connectionString))
connection.Open()
Dim cmd As SqlCommand = connection.CreateCommand()
DetachDatabase(dbName)
cmd.CommandText = String.Format("CREATE DATABASE {0} ON (NAME = N'{0}', FILENAME = '{1}')", dbName, dbFileName)
cmd.ExecuteNonQuery()
End Using
If (My.Computer.FileSystem.FileExists(dbFileName)) Then
Return True
Else
Return False
End If
Catch
Throw
End Try
End Function