Sunday, 18 August 2013

VB2008 displaying specific fields in the datagrid from a MySQL Search Result

VB2008 displaying specific fields in the datagrid from a MySQL Search Result

I design (php) db editors in the gaming world as a past time. I took up
the challenge of doing the same thing, but this time iwth VB (origianlly
6, but mysql is tricky) so am working with 2008.
One of the tables has a massive amount of info and I only need to display
4 or 5 fields from it as a search result (there are over 100+ fields)
I know how to populate the grid with the whole table, but do not know how
to do it via specific fields without going into a very long way around it.
This is my first time from vb6 to vb2008 - sadly not to impressed (looks
like they (M$) have deviated from "BASIC" and went for the C++ engine
format - super ugly (but I digress).
Try
conn.Open()
da = New MySqlDataAdapter(sqlQRY, conn)
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(da)
da.Fill(ds, "big_table")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "big_table"
Catch ex As Common.DbException
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
The above works fine, but I do not not need all 100+ fields displaying.
Just want player name, level, if they are online and a few other fields to
show - from here I can select a row and process the data elsewhere in the
program
Hope that made sense :-)

No comments:

Post a Comment