|
-
Nov 25th, 2009, 12:02 AM
#1
Thread Starter
Addicted Member
[RESOLVED] DataTable.Rows.Add Error
Hi all,
I am facing below problem. Your help is really appreciated.
Cannot perform '=' operation on System.Int32 and System.String.
What I tried to do here is I have a dataset get from SQL Express 2005 and I am adding a new row to it and it hit the above error.
I combine 3 tables in SQL and return the data to my win application.
And I add 1 row to it.
Here is the data type in my sql statement.
Code:
SELECT cd.indexNo, c.custid, c.companyname, c.contactperson, c.contactno,
dt.Type, cdm.DrawingMaterial, cd.Size, cd.Roundness
FROM rpts_customer As c, rpts_custdiesdetail As cd,
rpts_Type As dt, rpts_CustDrawMaterial As cdm
WHERE c.custID = cd.custID AND
cd.cdmNo = cdm.cdmNo AND
cd.dtNo = dt.dtNo AND
c.Active = 'TRUE'
ORDER BY dt.Type
indexNo = Integer (which is an auto increasement column in master table)
custID = Integer (same as indexNo, auto increase)
companyName = VarChar(50)
contactperson = VarChar(50)
contactno = VarChar(50)
Type = VarChar(50)
DrawingMaterial = VarChar(50)
Size = Numeric(10,6)
Roundness = Numeric(10,6)
dtNo = Int (auto increase)
cdmNo = Int (auto increase)
Active = Bit
And Here is my code in vb.net
VB.Net Code:
Dim dRow As DataRow = dSet.Tables("tblCustDetail").NewRow
dRow.Item(DBFN_IndexNo) = 1
dRow.Item(DBFN_CustID) = txtCustID.Text.Trim
dRow.Item(DBFN_CompanyName) = txtCompanyName.Text.Trim
dRow.Item(DBFN_ContactPerson) = txtContactPerson.Text.Trim
dRow.Item(DBFN_ContactNo) = txtContact.Text.Trim
dRow.Item(DBFN_Type) = cboType.Text
dRow.Item(DBFN_DrawingMaterial) = cboDrawingMaterial.Text
dRow.Item(DBFN_Size) = txtSize.Text.Trim
dRow.Item(DBFN_Roundness) = txtRoundness.Text.Trim
dSet.Tables("tblCustDetail").Rows.Add(dRow)
Anybody has any idea???
I'm out of solution. I checked the Database fields and its the same. No differences.
I don't know what should I do... 
Help..
Thanks.
scsfdev
-
Nov 25th, 2009, 12:22 AM
#2
Hyperactive Member
Re: DataTable.Rows.Add Error
what's the problem here? Error message?
If the post is heplful, Please Rate it
Chathura Wijekoon
-
Nov 25th, 2009, 12:27 AM
#3
Re: DataTable.Rows.Add Error
There is no need to set the values for the auto increment column. Remove this
Code:
dRow.Item(DBFN_IndexNo) = 1
dRow.Item(DBFN_CustID) = txtCustID.Text.Trim
Please mark you thread resolved using the Thread Tools as shown
-
Nov 25th, 2009, 12:37 AM
#4
Member
Re: DataTable.Rows.Add Error
Have you inserted this at the end?
Code:
da.Update(dSet)
dSet.AcceptChanges()
Where da is your dataadaptor. and you should have your insert commands as well.
as in here http://www.vbforums.com/showthread.php?t=466658
Last edited by reezan; Nov 25th, 2009 at 12:41 AM.
-
Nov 25th, 2009, 01:34 AM
#5
Thread Starter
Addicted Member
Re: DataTable.Rows.Add Error
 Originally Posted by Chathura
what's the problem here? Error message?
Hi chathra,
I'm finding the correct way of adding a new row.
 Originally Posted by reezan
Hi reezan,
Thanks for your info. The problem is I don't even get to this" Update" stage. I'm stuck at "Add Row".
 Originally Posted by danasegarane
There is no need to set the values for the auto increment column. Remove this
Code:
dRow.Item(DBFN_IndexNo) = 1
dRow.Item(DBFN_CustID) = txtCustID.Text.Trim
Hi danasegarane,
You solution solve my issue.
At first I only remove IndexNo but not tested with removing CustID field.
After I remove this CustID field, it's working!!!
thank you so much.
***********************
One thing strange is now i can keep IndexNo and remove CustID, it will pass. If i keep both or keep IndexNO and remove CustID, it will fail like above error message.
Any idea of why???
actually in my Customer Detail table, this custID is dummy field. and IndexNo is its identity key and auto increase one.
This custID is Identity key at customer table and set auto increase one.
I wonder what is the theory behind this DataTable.Row.Add related to this database field constraints.
Thanks for all.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|