Datagrid ( add row manually ) problem

A

Agnes

I got a Master-Detail relationship. Branch with dept (two tables) , as the
user input the Dept code, press 'Confirm' button,
I will select * from branch and input into the datatable mannually. the
dgBranchDept.datasource = myDataset. datamember= foreginconstraint_deptid.
I found the datatable got the data, but the datagrid display nothing. I
check the post before and try all the method. but still fail . please help

Here the following is my coding :---

drBranch = cmdBranch.ExecuteReader
dtSysBranchDept.BeginInit()
dgBranchDept.EndInit()
bmSysBranchDept.EndCurrentEdit()
Do While drBranch.Read
myDataRow = dtSysBranchDept.NewRow()
myDataRow.BeginEdit()
myDataRow.Item("branchid") = drBranch.Item("branchid")
myDataRow.item("deptid") = txtDeptId.Text
'MessageBox.Show(drBranch.Item("branchid")) <--- work fine
dtSysBranchDept.Rows.Add(myDataRow)
myDataRow.EndEdit()
Loop

drBranch.Close()
dtSysBranchDept.AcceptChanges()
Me.bmSysBranchDept.EndCurrentEdit()
dtSysBranchDept.EndInit()
 
C

Cor Ligthert

Agnes,

As far as I can see is this code you are is exactly the same as what does
the dataadapter.fill with except setting the constraints, and the properties
of the datatable.

However why are you showing it, in my opinion is only importent that the
databinding for this to the datagrid is probably

\\\
dgBranchDept.datasource = dtSysBranchDept
///

A lot of work, to do it this way, I am curious what is the reason for that?

Cor
 
A

Agnes

Dear Cor,
I found my error, as my previous post ( branchid's field size is not the
same) . After I correct. Everything go fines.\
(quit strang)
Anyway, thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top