求助 编译器错误消息: CS1061
编译器错误消息: CS1061: “System.Data.DataRow”不包含“SeriesID”的定义,并且找不到可接受类型为“System.Data.DataRow”的第一个参数的扩展方法“SeriesID”(是否缺少 using 指令或程序集引用?)
源错误:
行 62: //查询
行 63: var gz = from p in Sunlord101.AsEnumerable()
行 64: where p.SeriesID = "10101"
行 65: select p;
行 66: foreach (DataRow p in gz)
源码是:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetDataSet();
}
}
private void GetDataSet()
{
SqlConnection sqlcon = new SqlConnection();
SqlDataAdapter sda;
DataSet ds = new DataSet();
string sqlconstr = "Data Source=...;Initial Catalog=...;User ID=sa;Password=******";
sqlcon.ConnectionString = sqlconstr;
String sqlcmd = "SELECT SeriesID, TypeID, application, impedance, imp, DR, RC, LW, thickness FROM dbo.Sunlord101";
using (sda = new SqlDataAdapter(sqlcmd, sqlcon))
{
try
{
sda.Fill(ds, "Sunlord101");
Session["ds"] = ds;
}
catch (SystemException ex)
{
Response.Write(ex.Message.ToString());
}
}
GridView1.DataSource = ds.Tables["Sunlord101"].DefaultView;
GridView1.DataBind();
}
protected void lnkbtnGz_Click(object sender, EventArgs e)
{
DataSet ds = (DataSet)Session["ds"];
//对表中的字符串的区域信息进行设置,将不依赖于区域性
ds.Locale = CultureInfo.InvariantCulture;
//取得DataTable
DataTable Sunlord101 = ds.Tables["Sunlord101"];
try
{
//查询
var gz = from p in Sunlord101.AsEnumerable()
where p.SeriesID = "10101"
select p;
foreach (DataRow p in gz)
{
Response.Write(p.Field<int>("SeriesID")+"..." + p.Field<string>("TypeID") + "..."
+ p.Field<string>("application") + "..." + p.Field<string>("impedance") + "..."
+ p.Field<string>("imp") + "..." + p.Field<float>("DR") + "..."
+ p.Field<int>("RC") + "..." + p.Field<string>("LW") + "..."
+ p.Field<float>("thickness"));
Response.Write("<br>");
}
GridView1.Visible = false;
}
catch (InvalidCastException iex)
{
Response.Write(iex.Message.ToString());
}
catch (IndexOutOfRangeException oex)
{
Response.Write(oex.Message.ToString());
}
catch (NullReferenceException nex)
{
Response.Write(nex.Message.ToString());
}
}
protected void lnkbtnSz_Click(object sender, EventArgs e)
{
DataSet ds = (DataSet)Session["ds"];
ds.Locale = CultureInfo.InvariantCulture;
DataTable Sunlord101 = ds.Tables["Sunlord101"];
try
{
var sz = from p in Sunlord101.AsEnumerable()
where p.SeriesID = "10102"
select p;
foreach (DataRow p in sz)
{
Response.Write(p.Field<string>("TypeID") + "..."
+ p.Field<string>("application") + "..." + p.Field<string>("impedance") + "..."
+ p.Field<string>("imp") + "..." + p.Field<float>("DR") + "..."
+ p.Field<int>("RC") + "..." + p.Field<string>("LW") + "..."
+ p.Field<float>("thickness"));
Response.Write("<br>");
}
GridView1.Visible = false;
}
catch (InvalidCastException iex)
{
Response.Write(iex.Message.ToString());
}
catch (IndexOutOfRangeException oex)
{
Response.Write(oex.Message.ToString());
}
catch (NullReferenceException nex)
{
Response.Write(nex.Message.ToString());
}
}
protected void lnkbtnPz_Click(object sender, EventArgs e)
{
。。。。。。
前台:
<div style="float: left; width: 980px">
<table style="width: 95%;">
<tr>
<td class="item1">
<asp:LinkButton ID="lnkbtnGz" runat="server" onclick="lnkbtnGz_Click">GZ 系列</asp:LinkButton>
</td>
<td class="item1">
<asp:LinkButton ID="lnkbtnSz" runat="server" onclick="lnkbtnSz_Click">SZ 系列</asp:LinkButton>
</td>
<td class="item1">
<asp:LinkButton ID="lnkbtnPz" runat="server" onclick="lnkbtnPz_Click">PZ 系列</asp:LinkButton>
</td>
<td class="item1">
<asp:LinkButton ID="lnkbtnUpz" runat="server" onclick="lnkbtnUpz_Click">UPZ 系列</asp:LinkButton>
</td>
</tr>
<tr>
<td class="item1">
<asp:LinkButton ID="lnkbtnHz" runat="server" onclick="lnkbtnHz_Click">HZ 系列</asp:LinkButton>
</td>
<td class="item1">
<asp:LinkButton ID="lnkbtnHpz" runat="server" onclick="lnkbtnHpz_Click">HPZ 系列</asp:LinkButton>
</td>
<td class="item1">
<asp:LinkButton ID="lnkbtnGzc" runat="server" onclick="lnkbtnGzc_Click">GZ-C 系列</asp:LinkButton>
</td>
<td class="item1">
</td>
</tr>
</table>
</div>
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>