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

  • Thread starter Thread starter Agnes
  • Start date Start date
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
 
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
 
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")
 
Back
Top