Error :string or binary data would be truncated ???

A

Agnes

I loop myDatareader and insert the row into another datatable, as I update
the dataadaptor.
it return the above errors ??

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
 
C

Cor Ligthert

Hi Agnes,

Can you show the creation of that column "branchid" you are using?
Probably it has another type than the one you are reading.

Again why you are doing this while the fill does this automaticly.
(And there seems to be no noticeable performance difference because the
dataadapter.fill is using as well the datareader)

Cor
 
A

Agnes

Dear Cor,
I know what's wrong of my coding . In my drBranch.item("branchid") <--
it is char20. but in myDataRow. I define the field is char(10). That's why
there is any error.

myDataRow.Item("branchid") = drBranch.Item("branchid")
 

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