here is my code
DataTable dtBooking = new DataTable();
dtBooking = (GetGeneric.GetInstance
//dtBooking.Columns.Add("DriverID", Type.GetType("System.Int64"));
//dtBooking.Columns.Add("DriverDate", Type.GetType("System.DateTime"));
//dtBooking.Columns.Add("DriverName", Type.GetType("System.String"));
//int idCount = 1;
for (int i = 1; i <= 5; i++)
{
DataRow dr;
dr = dtBooking.NewRow();
dr["DriverID"] = dtBooking.Rows[0]["DriverID"];
dr["DriverName"] = dtBooking.Rows[0]["DriverName"];
dr["DriverDate"] = dtBooking.Rows[0]["DriverDate"];
dtBooking.Rows.Add(dr);
}
return dtBooking;
}
but I get this error
System.ArgumentException: Column '' does not belong to table Table1.
I am sure its is how I am calling the sproc, but I am unsure
Can anyone help?
Jiteendra SampathiraoPosted Aug 12, 2011, 1:09 AM
you are trying to get the value of the DataTable with the column name and the column isn't available(exists).
First check(trace) the condition whether the column exists or not using
if (Table.Columns.Contains("column_name"))
{
//
}
hope it help you........