View Single Post
 
Old November 13th, 2009, 04:32 PM
sandeepgupta26 sandeepgupta26 is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Application is crashing while assigning to DataRow

Please look at the following code:

Vals contains 2 fields and non empty

DataRow[] dr = m_dsOptions.Tables["TABLE"].Select("ID = '" + vals[0] + "'");
if (dr.Length <= 0) // name is not in list
{
DataRow newRow = m_dsOptions.Tables["TABLE_OPTIONS"].NewRow();
newRow[0] = vals[0];
newRow[1] = vals[1];
m_dsOptions.Tables["TABLE_OPTIONS"].Rows.Add(newRow);
}
else if (1 == dr.Length) //&& dr[0][0] == vals[0])
{
dr[0][1] = vals[1];
SG:----------^ while assign the new data to the table I am getting exception. Please let me know if I am writing the code correctly
}