Rick
asked on
VB - Fill only specific DataGridView columns from db query
Hello,
I have the following DataGridView in my form:
| Assignment | Name | ID Number | Location |
I have a database query that will select the "Name" and "ID Number" from a table.
"Assignment" and "Location" will be entered manually.
Later I will have a button to export the data from the DataGridView to another database table.
My question is, how do I tell vb to fill only the "Name" and "ID Number" columns from my query?
I'm using VB 08.
Thank you,
Rick
I have the following DataGridView in my form:
| Assignment | Name | ID Number | Location |
I have a database query that will select the "Name" and "ID Number" from a table.
"Assignment" and "Location" will be entered manually.
Later I will have a button to export the data from the DataGridView to another database table.
My question is, how do I tell vb to fill only the "Name" and "ID Number" columns from my query?
I'm using VB 08.
Thank you,
Rick
dgViewText = "SELECT Name, ID_Number FROM tbl_emp"
data = New DataTable
adapter = New MySqlDataAdapter(dgViewText, conn)
CommandBuild = New MySqlCommandBuilder(adapter)
adapter.Fill(data)
dgView.DataSource = data
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Name.DataFeild = "ID_Number"
Name.HeaderText = "ID Number"
should be
ID.DataFeild = "ID_Number"
ID.HeaderText = "ID Number"