I am new in Vb.NET and I have a code here which I got from example, which select one table. What I want is I want to select another tABLe.. I just want to select another table other than users.. since I have a another form which binds/call another table.
How will I do it?
Dim connection As MySql.Data.MySqlClient.MySqlConnection
Dim adapter As MySql.Data.MySqlClient.MySqlDataAdapter
Dim commandBldr As MySql.Data.MySqlClient.MySqlCommandBuilder
Dim command As MySql.Data.MySqlClient.MySqlCommand
Dim dataSet As System.Data.DataSet
Dim bindingSource1 As BindingSource
Private Sub btConnect_Click(sender As System.Object, e As System.EventArgs) Handles btConnect.Click
connection = New MySql.Data.MySqlClient.MySqlConnection
connection.ConnectionString = "user id=" & tbUserName.Text + "; password=" & tbPassword.Text & "; server=" & tbServer.Text & "; database=" & tbDatabase.Text & "; pooling=false;"
adapter = New MySql.Data.MySqlClient.MySqlDataAdapter
commandBldr = New MySql.Data.MySqlClient.MySqlCommandBuilder
command = New MySql.Data.MySqlClient.MySqlCommand
dataSet = New System.Data.DataSet
bindingSource1 = New BindingSource
commandBldr.DataAdapter = adapter
command.CommandText = "SELECT userID,pin, print1, print2 from users"
command.Connection = connection
adapter.SelectCommand = command
bindingSource1.DataSource = dataSet.Tables(0)
dgvUsers.DataSource = bindingSource1
Catch ex As Exception
dataSet = New DataSet
adapter.SelectCommand.CommandText = "select * from dtr"
You should be able to change the command text of your example query to match what you want to pull back. For example:
command.CommandText = "SELECT col1, col2 from newTable"