private void Page_Load(object sender, System.EventArgs e)
{
string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"C:\
Inetpub\wwwroot\wzgy\data\gydb.mdb" + ";";
OleDbConnection myCn = new OleDbConnection (connstr);
string sql = "select goods.id as 物资编码,goods.name as 物资名称,
goods.category_id as 类别,goods.quality as 型号,goods.units as 单位,
PORT_main.PORT_DATE as 日期,PORT_main.ID1 as 原始凭证,PORT_main.REMARK as 摘要,
PORT_ITEMS.AMOUNT as 数量 ,PORT_ITEMS.UNITPRICE as 单价,
PORT_ITEMS.jiner as 金额,PORT_main.IM_EX from goods,PORT_ITEMS,
PORT_main where PORT_ITEMS.GOODS_ID=goods.id and PORT_ITEMS.PORT_ID=PORT_main.ID"; OleDbCommand myComm = new OleDbCommand (sql,myCn );
myCn.Open ();
OleDbDataReader reader = myComm.ExecuteReader ();
while (reader.Read ())
{
if(reader["IM_EX"].ToString()=="I")
{
((Label)Repeater1.FindControl("Label1")).Text=reader["数量"].ToString();
((Label)Repeater1.FindControl("Label2")).Text=reader["单价"].ToString();
((Label)Repeater1.FindControl("Label3")).Text=reader["金额"].ToString();
((Label)Repeater1.FindControl("Label4")).Text="空";
((Label)Repeater1.FindControl("Label5")).Text="空";
((Label)Repeater1.FindControl("Label6")).Text="空";
}
else
{
((Label)Repeater1.FindControl("Label1")).Text="空";
((Label)Repeater1.FindControl("Label2")).Text="空";
((Label)Repeater1.FindControl("Label3")).Text="空";
((Label)Repeater1.FindControl("Label4")).Text=reader["数量"].ToString();
((Label)Repeater1.FindControl("Label5")).Text=reader["单价"].ToString();
((Label)Repeater1.FindControl("Label6")).Text=reader["金额"].ToString();
}
}
myCn.Close ();
myCn.Dispose ();
myComm.Dispose ();
reader.Close ();
}
试试这样可不可以
{
string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"C:\
Inetpub\wwwroot\wzgy\data\gydb.mdb" + ";";
OleDbConnection myCn = new OleDbConnection (connstr);
string sql = "select goods.id as 物资编码,goods.name as 物资名称,
goods.category_id as 类别,goods.quality as 型号,goods.units as 单位,
PORT_main.PORT_DATE as 日期,PORT_main.ID1 as 原始凭证,PORT_main.REMARK as 摘要,
PORT_ITEMS.AMOUNT as 数量 ,PORT_ITEMS.UNITPRICE as 单价,
PORT_ITEMS.jiner as 金额,PORT_main.IM_EX from goods,PORT_ITEMS,
PORT_main where PORT_ITEMS.GOODS_ID=goods.id and PORT_ITEMS.PORT_ID=PORT_main.ID"; OleDbCommand myComm = new OleDbCommand (sql,myCn );
myCn.Open ();
OleDbDataReader reader = myComm.ExecuteReader ();
while (reader.Read ())
{
if(reader["IM_EX"].ToString()=="I")
{
((Label)Repeater1.FindControl("Label1")).Text=reader["数量"].ToString();
((Label)Repeater1.FindControl("Label2")).Text=reader["单价"].ToString();
((Label)Repeater1.FindControl("Label3")).Text=reader["金额"].ToString();
((Label)Repeater1.FindControl("Label4")).Text="空";
((Label)Repeater1.FindControl("Label5")).Text="空";
((Label)Repeater1.FindControl("Label6")).Text="空";
}
else
{
((Label)Repeater1.FindControl("Label1")).Text="空";
((Label)Repeater1.FindControl("Label2")).Text="空";
((Label)Repeater1.FindControl("Label3")).Text="空";
((Label)Repeater1.FindControl("Label4")).Text=reader["数量"].ToString();
((Label)Repeater1.FindControl("Label5")).Text=reader["单价"].ToString();
((Label)Repeater1.FindControl("Label6")).Text=reader["金额"].ToString();
}
}
myCn.Close ();
myCn.Dispose ();
myComm.Dispose ();
reader.Close ();
}
试试这样可不可以
解决方案 »
- 主个功能要怎么实现
- 关于ASP.NET MVC3 动态输出ACTION语句并执行的问题
- Gridview根据Dropdownlist的值筛选,能否让DropDownList的默认值使GridView显示全部
- 在线等 怎样实现验证码的判断(要求要有必要的判断代码)
- MS自己真的在使用asp.net做网站吗?http://office.microsoft.com/zh-cn/clipart/FX101321032052.aspx?pid=CL100570202052
- 关于写入并保存Excel档案的问题
- ....用winform做一个简单的IE济览器,出了问题啊,请高手们帮忙 顶者有分....
- 关于DataGrid的一个问题.
- 数据绑定问题~???
- 连接WebService时出现"由于连接方在一段时间后没有正确答复或连接服务器失败
- 有关web控件的显示问题
- 100分求购用asp.net写的无刷新聊天室的源代码,一定要能运行呀
<HeaderTemplate>
<table width="100%" style="font:8pt verdana">
<tr style="BACKGROUND-COLOR: #ffecd8">
<th>
日期</th>
<th>
原始凭证</th>
<th>
摘要</th>
<th>
</th>
<th>
收入</th>
<th>
</th>
<th>
</th>
<th>
支出</th>
<th>
</th>
<th>
</th>
<th>
结余</th>
<th>
</th>
</tr>
<tr style="BACKGROUND-COLOR: #ffecd8">
<th>
</th>
<th>
</th>
<th>
</th>
<th>
数量</th>
<th>
单价</th>
<th>
金额</th>
<th>
数量</th>
<th>
单价</th>
<th>
金额</th>
<th>
数量</th>
<th>
单价</th>
<th>
金额</th>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 135px; POSITION: absolute; TOP: 211px" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<Th>
<asp:Label id="Label1" runat="server">
<%# DataBinder.Eval(Container.DataItem,"数量")%>
</asp:Label></Th>
<Th>
<asp:Label id="Label2" runat="server">
<%# DataBinder.Eval(Container.DataItem,"单价")%>
</asp:Label></Th>
<Th>
<asp:Label id="Label3" runat="server">
<%# DataBinder.Eval(Container.DataItem,"金额")%>
</asp:Label></Th>
<Th>
<asp:Label id="Label4" runat="server">
<%# DataBinder.Eval(Container.DataItem,"数量2")%>
</asp:Label></Th>
<Th>
<asp:Label id="Label5" runat="server">
<%# DataBinder.Eval(Container.DataItem,"单价2")%>
</asp:Label></Th>
<Th>
<asp:Label id="Label6" runat="server">
<%# DataBinder.Eval(Container.DataItem,"金额2")%>
</asp:Label></Th>
</TR>
</table>
</ItemTemplate>
<FooterTemplate>
</table></TABLE>
</FooterTemplate>
</asp:Repeater>
程序:
private void Page_Load(object sender, System.EventArgs e)
{
string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"C:\Inetpub\wwwroot\wzgy\data\gydb.mdb" + ";";
OleDbConnection myCn = new OleDbConnection (connstr);
string sql = "select goods.id as 物资编码,goods.name as 物资名称,goods.category_id as 类别,goods.quality as 型号,goods.units as 单位,PORT_main.PORT_DATE as 日期,PORT_main.ID1 as 原始凭证,PORT_main.REMARK as 摘要,PORT_ITEMS.AMOUNT as 数量,PORT_ITEMS.AMOUNT as 数量2, PORT_ITEMS.UNITPRICE as 单价,PORT_ITEMS.UNITPRICE as 单价2,PORT_ITEMS.jiner as 金额,PORT_ITEMS.jiner as 金额2,PORT_main.IM_EX from goods,PORT_ITEMS,PORT_main where PORT_ITEMS.GOODS_ID=goods.id and PORT_ITEMS.PORT_ID=PORT_main.ID";
OleDbDataAdapter adp = new OleDbDataAdapter(sql,myCn);
DataSet ds = new DataSet();
adp.Fill(ds,"goods");
for(int i=0;i<ds.Tables["goods"].Rows.Count;i++)
{
if(ds.Tables["goods"].Rows[i]["IM_EX"].ToString()=="I")
{
ds.Tables["goods"].Rows[i]["数量1"]="空";
ds.Tables["goods"].Rows[i]["单价1"]="空";
ds.Tables["goods"].Rows[i]["金额1"]="空";
}
else
{
ds.Tables["goods"].Rows[i]["数量"]="空";
ds.Tables["goods"].Rows[i]["单价"]="空";
ds.Tables["goods"].Rows[i]["金额"]="空";
}
}
Repeater1.DataSource = ds.Tables["goods"].DefaultView;
Repeater1.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"C:\Inetpub\wwwroot\wzgy\data\gydb.mdb" + ";";
OleDbConnection myCn = new OleDbConnection (connstr);
string sql = "select goods.id as 物资编码,goods.name as 物资名称,goods.category_id as 类别,goods.quality as 型号,goods.units as 单位,PORT_main.PORT_DATE as 日期,PORT_main.ID1 as 原始凭证,PORT_main.REMARK as 摘要,PORT_ITEMS.AMOUNT as 数量,PORT_ITEMS.AMOUNT as 数量2, PORT_ITEMS.UNITPRICE as 单价,PORT_ITEMS.UNITPRICE as 单价2,PORT_ITEMS.jiner as 金额,PORT_ITEMS.jiner as 金额2,PORT_main.IM_EX from goods,PORT_ITEMS,PORT_main where PORT_ITEMS.GOODS_ID=goods.id and PORT_ITEMS.PORT_ID=PORT_main.ID";
OleDbDataAdapter adp = new OleDbDataAdapter(sql,myCn);
DataSet ds = new DataSet();
adp.Fill(ds,"goods");
for(int i=0;i<ds.Tables["goods"].Rows.Count;i++)
{
if(ds.Tables["goods"].Rows[i]["IM_EX"].ToString()=="I")
{
ds.Tables["goods"].Rows[i]["数量2"]="空";
ds.Tables["goods"].Rows[i]["单价2"]="空";
ds.Tables["goods"].Rows[i]["金额2"]="空";
}
else
{
ds.Tables["goods"].Rows[i]["数量"]="空";
ds.Tables["goods"].Rows[i]["单价"]="空";
ds.Tables["goods"].Rows[i]["金额"]="空";
}
}
Repeater1.DataSource = ds.Tables["goods"].DefaultView;
Repeater1.DataBind();
}
--------------------------------------------------------------------------------列“数量2”不属于表 goods。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentException: 列“数量2”不属于表 goods。