Column 'column' does not belong to table Table

G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top