Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Column 'name' does not belong to table error !!

0 views
Skip to first unread message

Aruna Tennakoon

unread,
Aug 28, 2002, 7:54:28 PM8/28/02
to
Hi,
      I wrote following code,

DataSet dtSet = new DataSet();
SqlConnection sqlConn = new SqlConnection(strConn);
SqlDataAdapter sqldata = new SqlDataAdapter("SELECT * FROM test",strConn);
sqldata.Fill(dtSet,"test");
DataTable myTable = new DataTable();
DataRow myRow;
myRow = myTable.NewRow();
myRow["name"] = "John";
myRow["address"] = "Smith";
myTable.Rows.Add(myRow);

but in "myRow["name"] = "John";" line i am getting an error  ": Column 'name' does not belong to table ." plz help me on this

-Thanks
-Aruna

Per Hultqvist

unread,
Aug 29, 2002, 9:40:24 AM8/29/02
to
Aruna,

This error means that there is no column named "name" in the table "test".

Maybe these two rows are the problem :

myRow["name"] = "John"; ' Should column name be "firstname"?
myRow["address"] = "Smith"; ' Put last name in address-column? Should
be "lastname"?

Verify that all the columns you access exists in the table.

Hope it helps

/Per Hultqvist

0 new messages