TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
suprotim_dotnet
NA
13
0
I Couldnt Can U? (Master Detail Relationship)
Jun 10 2004 10:18 AM
Hi. I have 2 data grids,one at the top of a form and one at bottom of the form . Both have text boxes beneath them. As the user scrolls through the data grid he sees the corresponding values in the text boxes.The first grid contains the Centrals data and the 2nd grid contains the Devices data.I have coded that part except the problem is (Oki lemme tell u abt the daatbase) I have 4 tables Centrals Devices Groups DeviceTypes CentralID DeviceID Group_Id DeviceType_ID IP CentralID GroupDesc TCPPort Group_ID DeviceType_Id Now I have two combo boxes below the 2nd datagrid that display the group_id and DeviceType_ID from the devices table.I want that all the groups and all the devices shld be displayed in the combo. the problem is that it doesnt I have posted the code.What I want is that it should show me all the values of the groups and devicetypes in the 2 combo and that when i update the fields in the text boxes or the datagrid the database should also be updated on the click.The 2 update buttons will be below each datagrids along with the textboxes. ds = new DataSet(); String query = "Select * from Centrals"; da = new OleDbDataAdapter(query,ConfigurationSettings.AppSettings["MsAccess_ConnectString"]); DataTable centralDt = new DataTable("Centrals"); da.Fill(centralDt); ds.Tables.Add(centralDt); //Devices table String query1 = "Select * from Devices"; da = new OleDbDataAdapter(query1,ConfigurationSettings.AppSettings["MsAccess_ConnectString"]); DataTable deviceDt = new DataTable("Devices"); da.Fill(deviceDt); ds.Tables.Add(deviceDt); DataRelation dr = new DataRelation("Central_Devices_Relation", centralDt.Columns["Central_Id"], deviceDt.Columns["Central_Id"]); ds.Relations.Add(dr); dsView = ds.DefaultViewManager; dataGridCentral.DataSource = dsView; dataGridCentral.DataMember = "Centrals"; dataGridDevice.DataSource = dsView; dataGridDevice.DataMember = "Centrals.Central_Devices_Relation"; //Binding txt to the 1st datagrid txtCentralId.DataBindings.Add("Text", dsView,"Centrals.Central_Id"); txtDesc.DataBindings.Add("Text",dsView,"Centrals.CentralDescription"); txtIP.DataBindings.Add("Text",dsView,"Centrals.IP"); txtTCP.DataBindings.Add("Text",dsView,"Centrals.TCPPort"); txtConn.DataBindings.Add("Text",dsView,"Centrals.ConnectionTimeout"); txtShip.DataBindings.Add("Text",dsView,"Centrals.SendTimeout"); txtReception.DataBindings.Add("Text",dsView,"Centrals.ReceiveTimeout"); txtID.DataBindings.Add("Text",dsView,"Centrals.DeviceID"); txtStartAdd.DataBindings.Add("Text",dsView,"Centrals.RWStartAddress"); txtAddCnt.DataBindings.Add("Text",dsView,"Centrals.RWCount"); //Binding txt to 2nd dataGrid txtDevID.DataBindings.Add("Text",dsView,"Centrals.Central_Devices_Relation.Device_Id"); txtDevDesc.DataBindings.Add("Text",dsView,"Centrals.Central_Devices_Relation.DeviceDescription"); txtPort.DataBindings.Add("Text",dsView,"Centrals.Central_Devices_Relation.Port"); cboArmed.DataBindings.Add("Text",dsView,"Centrals.Central_Devices_Relation.Armed"); cmbType.DataSource = dsView; cmbType.DisplayMember = "Centrals.Central_Devices_Relation.DeviceType"; cmbGrp.DataSource = dsView; cmbGrp.DisplayMember = "Centrals.Central_Devices_Relation.Group_Id"; } } ----- Code for modification of data if(!ds.HasChanges(DataRowState.Modified)) return; DataSet xDataSet; xDataSet = ds.GetChanges(DataRowState.Modified); da.Update(xDataSet); MessageBox.Show("Data modified"); Thanks in advance.
Reply
Answers (
1
)
How do I insert data to a DB?
multiple sql statements in OLE DB command