0
我收到以下錯誤。使用LINQ到別名的DataSet查詢填充Gridview
在選定的 數據源中找不到名稱爲「P_ID」的字段或屬性。
我想用LINQ
綁定一個Gridview
到DataSet
。我有三張桌子,我想要他們的ID's
。在查詢中,我使用別名,但它給了我錯誤,因爲沒有找到別名。
這是我的代碼
string filterSO = "SELECT " +
"P.ID AS P_ID, " +
"S.ID AS S_ID, " +
" RS.LASTNAMER | | ' ' | | RS.FIRSTNAMER AS ReferentName, " +
" RS.ID," +
" P.STATUSP" +
" FROM PLANNING P," +
" SHIPPING S," +
" REFERENT_SHIPPING RS" +
" WHERE S.ID_REFERENT = RS.ID(+)" +
" AND S.ID_PLANNING = P.ID" +
" ORDER BY P.ID DESC";
using (OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["DBCS"].ToString()))
{
con.Open();
OracleCommand cmd = new OracleCommand(filterSO, con);
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet dss = new DataSet();
da.Fill(dss, "office_all");
Session["DATASET"] = dss;
var officee_all = from xx in dss.Tables["office_all"].AsEnumerable()
select new guards
{
ID = Convert.ToInt32(xx["P_ID"]),
ID_S = Convert.ToInt32(xx["S_ID"]),
LASTNAME_R = xx["LASTNAMER"].ToString(),
FIRSTNAME_R = xx["ReferentName"].ToString(),
ID_R = Convert.ToInt32(xx["ID"]),
STATUSP = xx["STATUSP"].ToString()
};
GridViewSOFirst.DataSource = officee_all.ToList();
GridViewSOFirst.DataBind();
你準確得出哪個錯誤? – Sybren
在所選數據源上找不到名稱爲「P_ID」的字段或屬性。 –