I’m trying to get record of a row using DataRow. Here’s what I’ve done so far:
uID = int.Parse(Request.QueryString["id"]);
PhotoDataSetTableAdapters.MembersTableAdapter mem = new PhotoDataSetTableAdapters.MembersTableAdapter();
PhotoDataSet.MembersDataTable memTable = mem.GetMemberByID(uID);
DataRow[] dr = memTable.Select("userID = uID");
string uName = dr["username"].ToString();
Then I got the error:
Cannot implicitly convert type ‘string’ to ‘int’
The error points to "username". I don’t know what’s wrong because I’m just trying to assign a string variable to a string value. Anyone figures out the reason of the error? Please help and thanks.
dris aDataRow[]not aDataRow, therefor the compiler complains that you pass a String when he needs anintfor the index.You actually want the username of the the single
DataRowin theDataTable, am i right?Note that this throws an exception if there is more than one row in the
DataTable. But since you pass an ID to theDataAdapter, i assume that it should return only one record.