Home All Groups Group Topic Archive Search About

Column 'column' does not belong to table Table

Author
21 Feb 2006 3:15 PM
Miro
I get this strange error:

Column 'PNR ' does not belong to table Table

It is strange because the columnname in the dataset is PNR.

String SQL = "SELECT PERSONNR AS PNR, ... FROM theTABLE";
OleDataAdapter.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
{
   String t1 = dr[0].ToString(); //gives correct value
   String t2 = ds.Tables[0].Columns[0].ColumnName; // gives "PNR"
   String t3 = dr["PNR"].ToString(); //Gives error, why?
}

I've tried to rename the column and even selected without alias. Same error.

AddThis Social Bookmark Button