Mondeo Posted November 16, 2006 Posted November 16, 2006 I have a simple database app, tab 1 has a datagrid on which is filled simply with SELECT * FROM Customers into a dataset/datatable which is then bound to the grid. Then if I double click a row it moves to tab 2, looks up cell 1 on the selected row of the datagrid (which is the primary key) and then does "SELECT * FROM Customers WHERE ID=id" into a datareader. On tab 2 I have loads of text boxes and I simply do txtname.text = rdr.item(0).tostring txtcompany. text = rdr.item(1).tostring And so on. Could someone explain the correct and accepted way of doing this task, i.e. using databinding etc. Should I create a customer class first with properties for my database fields? Then how to I do the binding etc. Thanks Quote
georgepatotk Posted November 17, 2006 Posted November 17, 2006 simple query using data reader Dim conn as new MySqlConnection(.......) If conn.State = ConnectionState.Closed Then conn.Open() End If Dim cmd As MySqlCommand Dim dtr As MySqlDataReader Dim query As String query = "your query" cmd = New MySqlCommand(query, conn) dtr = cmd.ExecuteReader While dtr.Read 'add items into data table/datagrid messagebox.show(dtr.item(0).tostring) End While dtr.Close() 'hope this help Quote George C.K. Low
Mondeo Posted November 17, 2006 Author Posted November 17, 2006 Hi George, Yes this is exactly what I have at the moment, but I want to learn more about using the more advanced (and probably quicker!) databinding features, like databinding to objects etc. Quote
georgepatotk Posted November 18, 2006 Posted November 18, 2006 how about this? http://www.xtremedotnettalk.com/showthread.php?p=407955#post407955 Quote George C.K. Low
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.