I suck at working with DataGridView and datasets, but I think working through this problem will help me get a better understanding. I've been trying to find applicable reading on this stuff, but its pretty hard to sort through.
I have a mySQL database I am connecting to, and I want to fill a datagridview with the results. I am building a much more complex SQL statement, but this works for my example.
I basically just need the id to be hidden, so that when I click on either the location or date cell, I get that rows ID. I don't want the id row in the DataGridView. Also, I want to be able to format the date differently than it is stored in the mySQL database. What that boils down to is being able to manipulate data in the DataTable before it gets bound to the DataGridView.Code:dim sSQL as string = "SELECT date, location, id FROM tbl_docs" Dim connStr As String = String.Format("Server={0};Port={1};Database={2};Uid={3};Pwd={4};", DB_SERVER, DB_PORT, DB_DATABASE, DB_USER, DB_PASS) Try conn = New MySqlConnection(connStr) conn.Open() data = New DataTable da = New MySqlDataAdapter(sSQL, conn) cb = New MySqlCommandBuilder(da) da.Fill(data) dataResults.DataSource = data
Probably a easy question to answer... Any ideas?




Reply With Quote