Not a long story.
1) Create a connection
2) Create a command containing the same SQL you would use to create it manually
Dim strSQL As String = "CREATE TABLE GRP_CONFIG ( " + _
"SHORT_NAME VARCHAR(8) NOT NULL " + _
"TG_NAME VARCHAR(8) NOT NULL )"
Dim csb As New SqlConnectionStringBuilder("connection info goes here")
Dim conn As New SqlConnection(csb.ToString())
Dim cmd As New SqlCommand(strSQL, conn)
say I want to create a table upon clicking a button. Will I insert the whole thing within the sub of the button including the 'Imports System.Data.SqlClient'? And there is a module there. Don't really know where to put things here...
I would put that in a different Sub -- actually I would make it a function that returns a Boolean (false if table not created) and then call it from the button push.
I would not put all of that code IN the button-push itself.
As a matter of fact, if you're doing a lot of database interaction, you could make a new class of database related code and put it there.
I have just heard of them and in my Myapp.config file, there are computer-generated codes there where I saw something like it. So how would the code look like? Can you just repost it here? The table creation takes place when a button is clicked.