using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;public partial class ViewGuzhang : System.Web.UI.Page
{
public string shijian1, shijian2, didian, leibie, leixing, xianxiang, yuanyin, banfa, jieguo, renyuan;
protected void Page_Load(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["WHConn"].ConnectionString;
SqlConnection conn = new SqlConnection(constr);
conn.Open();
string comstr = "select * from gzhz where 序号="+Request.QueryString["id"];
string gcomstr = "select convert(varchar(10),故障时间,120) from gzhz where 序号=" + Request.QueryString["id"];
string wcomstr = "select convert(varchar(10),维修时间,120) from gzhz where 序号=" + Request.QueryString["id"];
SqlDataAdapter da = new SqlDataAdapter(comstr,conn);
SqlDataAdapter gda = new SqlDataAdapter(gcomstr, conn);
SqlDataAdapter wda = new SqlDataAdapter(wcomstr, conn);
DataSet ds = new DataSet();
da.Fill(ds,"all");
gda.Fill(ds,"gtime");
wda.Fill(ds,"wtime");
DataRow dr = ds.Tables["all"].Rows[0];
DataRow gdr = ds.Tables["gtime"].Rows[0];
DataRow wdr = ds.Tables["wtime"].Rows[0]; shijian1 = gdr["故障时间"].ToString();
shijian2 = wdr["维修时间"].ToString();
didian = dr["故障地点"].ToString();
leibie = dr["系统类别"].ToString();
leixing = dr["设备类型"].ToString();
xianxiang = dr["故障现象"].ToString();
yuanyin = dr["故障原因"].ToString();
banfa = dr["处理办法"].ToString();
jieguo = dr["处理结果"].ToString();
renyuan = dr["参与人员"].ToString();
}
}会有以下错误提示,这是为什么呢?异常详细信息: System.ArgumentException: 列“故障时间”不属于表 gtime。源错误:
行 35: DataRow wdr = ds.Tables["wtime"].Rows[0];
行 36:
行 37: shijian1 = gdr["故障时间"].ToString();
行 38: shijian2 = wdr["维修时间"].ToString();
行 39: didian = dr["故障地点"].ToString();
源文件: c:\Inetpub\wwwroot\ViewGuzhang.aspx.cs 行: 37
解决方案 »
- string 和stringbuilder的使用?
- 跪求高人给我转一下:Ap(.htaccess)文件转iis-Rewrite(http.ini)规则追分至谢
- VS2005转到定义无法转到同一方案的另一个项目中方法定义
- 帮帮忙啊,谢谢大家
- 用VS2003怎么样控制多人开发同一个项目呀....
- 怎样在C#中获得当前桌面上最前端活动应用程序的名称啊
- 请刚工作一两个月的程序员回答谢谢
- <在 ASP.NET 中使用 HTTPHandler 实现 Front Controller>为什么不写成《在 ASP.NET 中使用 IHTTPHandler 实现 Front Controller》?
- 能不能把用C#写的ActiveX控件安装到IE工具栏,就像Google的工具栏控件一样,在地址栏下方显示。██████
- 用sqldatareader在datagrid里显示
- 求助啊!!请问c#定时器线程名怎么获得??可以获得吗??
- 请教:进度条的问题?
string gcomstr = "select convert(varchar(10),故障时间,120) as 故障时间 from gzhz where 序号=" + Request.QueryString["id"];
string wcomstr = "select convert(varchar(10),维修时间,120) as 维修时间 from gzhz where 序号=" + Request.QueryString["id"];
不过这个as...概念不明白,呵呵 。
另外,我上面的代码是不是有一些没有必要?感觉我重复了很多东西。
as 是起别名的意思
一开始你的语句查询出来的一列没有起别名,默认的列名就是未命名