Need help on basic operations with data from data sources
I know how to work with data from an sql database, if i do it the manual way (coding/sql-queries). But i want to learn how to do it "the Microsoft way".
I have added a Datasource: "_myDatabaseDataset" (myTable contains fields ID and Name).
I have dragged the ID column onto my form as a combobox.
Whenever i change the value (SelectedIndexChanged) i want a messagebox showing "Name" of the ID that is selected. How do i do that?
MessageBox.Show(?);
(also, if anyone have a link to some tutorials that demonstrate how to work with data from Data sources (database) that would be nice.)
Using Visual Studio 2005 btw.
DataRowView curRowView = (DataRowView)this.DataTable1BindingSource.Current; MessageBox.Show(curRowView["Name"].ToString());
// You can extend this code to extract typed row.
DataSet1.DataTable1Row curRow = (DataSet1.DataTable1Row)curRowView.Row;
MessageBox.Show(curRow.Name);
Of course check if all types are right. If you have other tables defined curRowView.Row can be not DataTable1Row and you will have exception.
Thanks for you reply. That worked, but not quite as i expected.
What i really am working with is the following:
I have dragged a the ID field as a Combobox to my form
I have dragged "Name" as a textfield to my form.
Whenever i change selection in my combobox, the Name textfield is automaticly updated. So far so good, but the table also have a "Picture" field, with the name of the picture file.
What i want is a picturebox, with an image that also updates together with the Name textbox, according to what i select in the ID combobox...
Does anyone have an idea how i can fix that without too much coding?