Please pardon me for my English grammar.
I'm currently coding a system and I was wondering if you could establish a new connection after you created a database in a server.
This is the Connection String:
Dim DBCon As SqlConnection = New SQLConnection("Data Source=(localdb)\DbLocal;Integrated Security=True")
If I want to create a database I use a command - the database name is bounded after a textbox, it goes like:
Dim dbName As String = txtdbName.Text
myCommand = "CREATE database " & dbName
The database gets created, but after I start a query that creates a table - the table does not save in the created database. So with my beginner skills in VB.Net and MSSQL, I deduced it was because of my Connection String, so I tried messing with it:
Dim myConnectionString As SqlConnection = New SqlConnection("Data Source=(localdb)\DbLocal;Database=" & dbName & ";Integrated Security=True;Pooling=False")
I wrote the above code before the create a table query, but after I run it, the tables I created in the query didn't go to the database. I was wondering if there's a 'right' way to do this. I tried mixing different codes that I found online, but they produce the same result.
Edit: My create table query:
myCommand = "CREATE TABLE tblPerson (PersonID int, LastName varchar(300), FirstName varchar(300), Address varchar(300), City varchar(300))"