B
Beringer
I am having a problem referencing data from a data view using a SQL query
that utilizes the same table twice using aliases for the tables as shown
below:
string command = "SELECT User1.Name, User2.Name FROM myTable " +
"JOIN [Users] AS User1 ON User1.ID = myTable.User1ID " +
"JOIN [Users] AS User2 ON User2.ID = myTable.User2ID " +
"WHERE...";
I perform the query and fill a dataset successfully! I then get a dataview
and access the data as follows:
DataView dv = dataSet.Tables[0].DefaultView
DataRowView drv = dv[0];
string user1Name = (string)drv["User1.Name"];
string user2Name = (string)drv["User2.Name"];
When this code is executed I get a runtime exception that says:
"User1.Name is neither a DataColumn or DataRelation in table myTable."
Can someone tell me what is wrong here? How do I reference the the
different names?
Thank you in advance,
Eric
that utilizes the same table twice using aliases for the tables as shown
below:
string command = "SELECT User1.Name, User2.Name FROM myTable " +
"JOIN [Users] AS User1 ON User1.ID = myTable.User1ID " +
"JOIN [Users] AS User2 ON User2.ID = myTable.User2ID " +
"WHERE...";
I perform the query and fill a dataset successfully! I then get a dataview
and access the data as follows:
DataView dv = dataSet.Tables[0].DefaultView
DataRowView drv = dv[0];
string user1Name = (string)drv["User1.Name"];
string user2Name = (string)drv["User2.Name"];
When this code is executed I get a runtime exception that says:
"User1.Name is neither a DataColumn or DataRelation in table myTable."
Can someone tell me what is wrong here? How do I reference the the
different names?
Thank you in advance,
Eric