首页 新闻 会员 周边 捐助

为什么网站访问量一大,程序就出现以下的这个错误?

0
悬赏园豆:200 [已解决问题] 解决于 2010-07-23 17:59

“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

UId
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.IndexOutOfRangeException: UId

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 

堆栈跟踪:


[IndexOutOfRangeException: UId]
   System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +4839010
   System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +67
   System.Data.SqlClient.SqlDataReader.get_Item(String name) +15
   KaiSheng.CIM.DAL.UserInfoService.Login(String uname, String upwd) in D:\KaiSheng_CIM_System\KaiSheng_CIM_DAL\UserInfoService.cs:201
   KaiSheng.CIM.BLL.UserInfoManager.login(String uname, String upwd) in D:\KaiSheng_CIM_System\KaiSheng_CIM_BLL\UserInfoManager.cs:46
   _Default.imgLogin_Click(Object sender, ImageClickEventArgs e) +366
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +108
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +118
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 


--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.3603; ASP.NET 版本:2.0.50727.3082

数据操作代码:

代码
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using KaiSheng.CIM.Models;

namespace KaiSheng.CIM.DAL
{
public static class ExhaleInfoService
{
/// <summary>
/// 添加客户信息
/// </summary>
/// <param name="ea"></param>
/// <returns></returns>
public static int add(ExhaleInfo ea)
{
string sql = string.Format("INSERT INTO ExhaleInfo VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',{6},{7},{8},'{9}','{10}',{11},0,'{12}')",ea.TowerId,ea.Name, ea.Tel, ea.AddRess, ea.General, ea.TrackConditions, ea.ClientState, ea.ResultType, ea.GroupType, ea.TransitionTime, ea.GongSiName, ea.UId, ea.CreateTime);
return DBHelper.ExecuteCommand(sql);
}

/// <summary>
/// 查询客户信息
/// </summary>
/// <param name="pageno">页码</param>
/// <param name="no">显示数量</param>
/// <param name="key">搜索条件</param>
/// <returns></returns>
public static List<ExhaleInfo> show(int pageno,int no,string key)
{
List
<ExhaleInfo> list = new List<ExhaleInfo>();
string sql = string.Format("SELECT TOP {0} * FROM ExhaleInfo WHERE EId NOT IN (SELECT TOP ({1}*{2}) EId FROM ExhaleInfo WHERE 1=1 {3}) {3}", no, pageno, no, key);
using (SqlDataReader Reader = DBHelper.GetReader(sql))
{
if (!Reader.HasRows)
{
list
= null;
}
else
{
while (Reader.Read())
{
ExhaleInfo ea
= new ExhaleInfo();
ea.TowerId
= Reader["TowerId"].ToString();
ea.EId
= Convert.ToInt32(Reader["EId"]);
ea.Name
= Reader["Name"].ToString();
ea.Tel
= Reader["Tel"].ToString();
ea.AddRess
= Reader["Address"].ToString();
ea.General
= Reader["General"].ToString();
ea.TrackConditions
= Reader["TrackConditions"].ToString();
ea.ClientState
= Convert.ToInt32(Reader["ClientState"]);
ea.ResultType
= Convert.ToInt32(Reader["ResultType"]);
ea.GroupType
= Convert.ToInt32(Reader["GroupType"]);
ea.TransitionTime
= Reader["TransitionTime"].ToString();
ea.GongSiName
= Reader["GongSiName"].ToString();
ea.UId
= Convert.ToInt32(Reader["UId"]);
ea.IfUse
= Convert.ToInt32(Reader["IfUse"]);
ea.CreateTime
= Convert.ToDateTime(Reader["CreateTime"]);
list.Add(ea);
}
Reader.Close();
}
}
return list;
}

/// <summary>
/// 根据ID查询客户信息
/// </summary>
/// <param name="eid">客户ID</param>
/// <returns></returns>
public static ExhaleInfo SelectExhaleInfoByEId(int eid)
{
ExhaleInfo ea
= new ExhaleInfo();
string sql = string.Format("SELECT EId,TowerId,Name,Tel FROM ExhaleInfo WHERE EId={0}",eid);
using (SqlDataReader Reader = DBHelper.GetReader(sql))
{
if (!Reader.HasRows)
{
ea
= null;
}
else
{
if (Reader.Read())
{
ea.TowerId
= Reader["TowerId"].ToString();
ea.EId
= Convert.ToInt32(Reader["EId"]);
ea.Name
= Reader["Name"].ToString();
ea.Tel
= Reader["Tel"].ToString();
}
}
}
return ea;
}

/// <summary>
/// 读取总数
/// </summary>
/// <returns></returns>
public static int ReadCount()
{
string sql = "SELECT COUNT(*) FROM ExhaleInfo";
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 根据搜索条件读取总数
/// </summary>
/// <param name="key">搜索条件</param>
/// <returns></returns>
public static int ReadCount(string key)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE 1=1 {0} ",key);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 更改客户状态
/// </summary>
/// <param name="cid">状态类型ID</param>
/// <param name="time">时间</param>
/// <param name="eid">客户ID</param>
/// <returns></returns>
public static int ChangeCilentState(int cid,DateTime time,int eid)
{
string sql = string.Format("UPDATE ExhaleInfo SET ClientState={0},TransitionTime='{1}' WHERE EId={2}", cid, time, eid);
return DBHelper.ExecuteCommand(sql);
}

/// <summary>
/// 分配客户名单至小组
/// </summary>
/// <param name="gid">组ID</param>
/// <param name="num">分配数量</param>
/// <returns></returns>
public static int DistributionExhaleByGroup(int gid,int num)
{
string sql = string.Format("UPDATE ExhaleInfo SET GroupType={0} WHERE EId IN (SELECT TOP {1} EId FROM ExhaleInfo WHERE IfUse=0)",gid,num);
return DBHelper.ExecuteCommand(sql);
}

/// <summary>
/// 分配客户名单至用户
/// </summary>
/// <param name="uid">用户ID</param>
/// <param name="num">分配数量</param>
/// <returns></returns>
public static int DistributionExhaleByUser(int uid, int num)
{
string sql = string.Format("UPDATE ExhaleInfo SET UId={0},IfUse=1 WHERE EId IN (SELECT TOP {1} EId FROM ExhaleInfo WHERE IfUse=0)", uid, num);
return DBHelper.ExecuteCommand(sql);
}


/// <summary>
/// 手工分配客户名单至用户
/// </summary>
/// <param name="uid">用户ID</param>
/// <param name="eids">客户ID</param>
/// <returns></returns>
public static int DistributionExhalePeopleByUser(int uid, string eids)
{
string sql = string.Format("UPDATE ExhaleInfo SET UId={0},IfUse=1 WHERE EId IN ( {1} )", uid, eids);
return DBHelper.ExecuteCommand(sql);
}

/// <summary>
/// 手工分配客户名单至小组
/// </summary>
/// <param name="gid">组ID</param>
/// <param name="eids">客户ID</param>
/// <returns></returns>
public static int DistributionExhalePeopleByGroup(int gid, string eids)
{
string sql = string.Format("UPDATE ExhaleInfo SET GroupType={0},IfUse=0 WHERE EId IN ( {1} )", gid, eids);
return DBHelper.ExecuteCommand(sql);
}

/// <summary>
/// 组长分配客户名单至组内成员
/// </summary>
/// <param name="uid">用户ID</param>
/// <param name="num">分配数量</param>
/// <param name="gid">组ID</param>
/// <returns></returns>
public static int DistributionExhaleByGroupAdmin(int uid,int num,int gid)
{
string sql = string.Format("UPDATE ExhaleInfo SET UId={0},IfUse=1 WHERE EId IN (SELECT TOP {1} EId FROM ExhaleInfo WHERE IfUse=0 AND GroupType={2})",uid,num,gid);
return DBHelper.ExecuteCommand(sql);
}

/// <summary>
/// 读取用户成交客户总数
/// </summary>
/// <param name="uid">用户ID</param>
/// <returns></returns>
public static int ReadCJExhaleCountByUId(int uid)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE UId={0} AND ClientState=3", uid);
return DBHelper.GetScalar(sql);
}


/// <summary>
/// 读取组成交客户总数
/// </summary>
/// <param name="gid">组ID</param>
/// <returns></returns>
public static int ReadCJExhaleCountByGId(int gid)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE GroupType={0} AND ClientState=3", gid);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取用户跟进客户总数
/// </summary>
/// <param name="uid">用户ID</param>
/// <returns></returns>
public static int ReadGJExhaleCountByUId(int uid)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE UId={0} AND ClientState=2", uid);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取组跟进客户总数
/// </summary>
/// <param name="gid">组ID</param>
/// <returns></returns>
public static int ReadGJExhaleCountByGId(int gid)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE GroupType={0} AND ClientState=2", gid);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取用户的客户名单总数
/// </summary>
/// <param name="uid">用户ID</param>
/// <returns></returns>
public static int ReadExhaleCountByUId(int uid)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE UId={0}", uid);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取组的客户名单总数
/// </summary>
/// <param name="gid">组ID</param>
/// <returns></returns>
public static int ReadExhaleCountByGId(int gid)
{
string sql = string.Format("SELECT COUNT(*) FROM ExhaleInfo WHERE GroupType={0}", gid);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 根据组编号读取成交客户信息
/// </summary>
/// <param name="gid">组编号</param>
/// <returns></returns>
public static List<ExhaleInfo> ShowCJExhaleInfoByGId(int gid)
{
List
<ExhaleInfo> list = new List<ExhaleInfo>();
string sql = string.Format("SELECT * FROM ExhaleInfo WHERE grouptype={0} AND ClientState=3", gid);
using (SqlDataReader Reader = DBHelper.GetReader(sql))
{
if (!Reader.HasRows)
{
list
= null;
}
else
{
while (Reader.Read())
{
ExhaleInfo ea
= new ExhaleInfo();
ea.TowerId
= Reader["TowerId"].ToString();
ea.EId
= Convert.ToInt32(Reader["EId"]);
ea.Name
= Reader["Name"].ToString();
ea.Tel
= Reader["Tel"].ToString();
ea.AddRess
= Reader["Address"].ToString();
ea.General
= Reader["General"].ToString();
ea.TrackConditions
= Reader["TrackConditions"].ToString();
ea.ClientState
= Convert.ToInt32(Reader["ClientState"]);
ea.ResultType
= Convert.ToInt32(Reader["ResultType"]);
ea.GroupType
= Convert.ToInt32(Reader["GroupType"]);
ea.TransitionTime
= Reader["TransitionTime"].ToString();
ea.GongSiName
= Reader["GongSiName"].ToString();
ea.UId
= Convert.ToInt32(Reader["UId"]);
ea.IfUse
= Convert.ToInt32(Reader["IfUse"]);
ea.CreateTime
= Convert.ToDateTime(Reader["CreateTime"]);
list.Add(ea);
}
}
}
return list;
}

/// <summary>
/// 根据组编号读取跟进客户信息
/// </summary>
/// <param name="gid">组编号</param>
/// <returns></returns>
public static List<ExhaleInfo> ShowGJExhaleInfoByGId(int gid)
{
List
<ExhaleInfo> list = new List<ExhaleInfo>();
string sql = string.Format("SELECT * FROM ExhaleInfo WHERE grouptype={0} AND ClientState=2", gid);
using (SqlDataReader Reader = DBHelper.GetReader(sql))
{
if (!Reader.HasRows)
{
list
= null;
}
else
{
while (Reader.Read())
{
ExhaleInfo ea
= new ExhaleInfo();
ea.TowerId
= Reader["TowerId"].ToString();
ea.EId
= Convert.ToInt32(Reader["EId"]);
ea.Name
= Reader["Name"].ToString();
ea.Tel
= Reader["Tel"].ToString();
ea.AddRess
= Reader["Address"].ToString();
ea.General
= Reader["General"].ToString();
ea.TrackConditions
= Reader["TrackConditions"].ToString();
ea.ClientState
= Convert.ToInt32(Reader["ClientState"]);
ea.ResultType
= Convert.ToInt32(Reader["ResultType"]);
ea.GroupType
= Convert.ToInt32(Reader["GroupType"]);
ea.TransitionTime
= Reader["TransitionTime"].ToString();
ea.GongSiName
= Reader["GongSiName"].ToString();
ea.UId
= Convert.ToInt32(Reader["UId"]);
ea.IfUse
= Convert.ToInt32(Reader["IfUse"]);
ea.CreateTime
= Convert.ToDateTime(Reader["CreateTime"]);
list.Add(ea);
}
}
}
return list;
}

/// <summary>
/// 根据用户编号读取跟进客户信息
/// </summary>
/// <param name="uid">用户编号</param>
/// <returns></returns>
public static List<ExhaleInfo> ShowGJExhaleInfoByUId(int uid)
{
List
<ExhaleInfo> list = new List<ExhaleInfo>();
string sql = string.Format("SELECT * FROM ExhaleInfo WHERE UId={0} AND ClientState=2", uid);
using (SqlDataReader Reader = DBHelper.GetReader(sql))
{
if (!Reader.HasRows)
{
list
= null;
}
else
{
while (Reader.Read())
{
ExhaleInfo ea
= new ExhaleInfo();
ea.TowerId
= Reader["TowerId"].ToString();
ea.EId
= Convert.ToInt32(Reader["EId"]);
ea.Name
= Reader["Name"].ToString();
ea.Tel
= Reader["Tel"].ToString();
ea.AddRess
= Reader["Address"].ToString();
ea.General
= Reader["General"].ToString();
ea.TrackConditions
= Reader["TrackConditions"].ToString();
ea.ClientState
= Convert.ToInt32(Reader["ClientState"]);
ea.ResultType
= Convert.ToInt32(Reader["ResultType"]);
ea.GroupType
= Convert.ToInt32(Reader["GroupType"]);
ea.TransitionTime
= Reader["TransitionTime"].ToString();
ea.GongSiName
= Reader["GongSiName"].ToString();
ea.UId
= Convert.ToInt32(Reader["UId"]);
ea.IfUse
= Convert.ToInt32(Reader["IfUse"]);
ea.CreateTime
= Convert.ToDateTime(Reader["CreateTime"]);
list.Add(ea);
}
}
}
return list;
}

/// <summary>
/// 根据用户编号读取成交客户信息
/// </summary>
/// <param name="uid">用户编号</param>
/// <returns></returns>
public static List<ExhaleInfo> ShowCJExhaleInfoByUId(int uid)
{
List
<ExhaleInfo> list = new List<ExhaleInfo>();
string sql = string.Format("SELECT * FROM ExhaleInfo WHERE UId={0} AND ClientState=3", uid);
using (SqlDataReader Reader = DBHelper.GetReader(sql))
{
if (!Reader.HasRows)
{
list
= null;
}
else
{
while (Reader.Read())
{
ExhaleInfo ea
= new ExhaleInfo();
ea.TowerId
= Reader["TowerId"].ToString();
ea.EId
= Convert.ToInt32(Reader["EId"]);
ea.Name
= Reader["Name"].ToString();
ea.Tel
= Reader["Tel"].ToString();
ea.AddRess
= Reader["Address"].ToString();
ea.General
= Reader["General"].ToString();
ea.TrackConditions
= Reader["TrackConditions"].ToString();
ea.ClientState
= Convert.ToInt32(Reader["ClientState"]);
ea.ResultType
= Convert.ToInt32(Reader["ResultType"]);
ea.GroupType
= Convert.ToInt32(Reader["GroupType"]);
ea.TransitionTime
= Reader["TransitionTime"].ToString();
ea.GongSiName
= Reader["GongSiName"].ToString();
ea.UId
= Convert.ToInt32(Reader["UId"]);
ea.IfUse
= Convert.ToInt32(Reader["IfUse"]);
ea.CreateTime
= Convert.ToDateTime(Reader["CreateTime"]);
list.Add(ea);
}
}
}
return list;
}

/// <summary>
/// 根据楼盘查询楼盘ID
/// </summary>
/// <param name="name">楼盘名称</param>
/// <returns></returns>
public static string ReadTowerIdByTName(string name)
{
string sql = string.Format("SELECT TowerId FROM TowerInfo WHERE TowerName='{0}'", name);
object o = DBHelper.XluoGetScalar(sql);
if (o == null)
{
return "";
}
else
{
return o.ToString();
}
}

/// <summary>
/// 读取所有未分配的客户名单总数
/// </summary>
/// <returns></returns>
public static int ReadNoUseCount()
{
string sql = string.Format("SELECT COUNT(EId) FROM ExhaleInfo WHERE GroupType=1");
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取组内未分配的客户名单总数
/// </summary>
/// <param name="gid">组ID</param>
/// <returns></returns>
public static int ReadNoUseCount(int gid)
{
string sql = string.Format("SELECT COUNT(EId) FROM ExhaleInfo WHERE IfUse=0 AND GroupType={0}", gid);
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取所有已分配的客户名单总数
/// </summary>
/// <returns></returns>
public static int ReadYesUseCount()
{
string sql = string.Format("SELECT COUNT(EId) FROM ExhaleInfo WHERE GroupType!=1");
return DBHelper.GetScalar(sql);
}

/// <summary>
/// 读取组内已分配的客户名单总数
/// </summary>
/// <param name="gid">组ID</param>
/// <returns></returns>
public static int ReadYesUseCount(int gid)
{
string sql = string.Format("SELECT COUNT(EId) FROM ExhaleInfo WHERE IfUse=1 AND GroupType={0}", gid);
return DBHelper.GetScalar(sql);
}


}
}

 

 

 表示层代码:

代码
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using KaiSheng.CIM.BLL;
using KaiSheng.CIM.Models;

public partial class ExhaleManager_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
gvBind();
//showgj();
}
}

public void bind()
{
this.ckListUserState.DataSource = ClientStateManager.show();
this.ckListUserState.DataBind();

//this.ddlGroupType.DataSource = UserGroupManager.show();
//this.ddlGroupType.DataBind();

//this.ddlUserList.DataSource = UserInfoManager.Show(" AND 1=1");
//this.ddlUserList.DataBind();
}

public void gvBind()
{
UserInfo u
=Session["USER"] as UserInfo;
int pageno = 0;
int pagecount = 0;
int count = 0;
int nowno=0;
string key = "";
if (Request.QueryString["pageno"] == null)
{
pageno
= 0;
}
else
{
pageno
= Convert.ToInt32(Request.QueryString["pageno"]);
}

if (Session["ExhaleKey"] == null)
{
string s = " AND UId=" + u.UId + "";
ViewState[
"s"] = s;
count
= ExhaleInfoManager.ReadCount(s);
pagecount
= ExhaleInfoManager.ReadPageCount(s,10);
key
= " AND UId=" + u .UId+ "";
Session[
"ExhaleKey"] = key;
}
else
{
count
= ExhaleInfoManager.ReadCount(Session["ExhaleKey"].ToString());
pagecount
= ExhaleInfoManager.ReadPageCount(Session["ExhaleKey"].ToString(), 10);
key
= Session["ExhaleKey"].ToString();
}
this.lblPageNoCount.Text = "";
nowno
= pageno + 1;
this.lblCount.Text = count.ToString();
this.lblPageCount.Text = pagecount.ToString();
this.lblPageNo.Text = nowno.ToString();

string onePage = "";
string upPage = "";
string nextPage = "";
string endPage = "";
if (pageno == 0)
{
onePage
= "<a href='#'>首页</a>";
upPage
= "<a href='#'>上一页</a>";
nextPage
= "<a href='Default.aspx?pageno=" + (pageno + 1) + "'>下一页</a>";
endPage
= "<a href='Default.aspx?pageno=" + (pagecount - 1) + "'>末页</a>";
}
else if (pageno == (pagecount - 1))
{
onePage
= "<a href='Default.aspx?pageno=0'>首页</a>";
upPage
= "<a href='Default.aspx?pageno=" + (pageno - 1) + "'>上一页</a>";
nextPage
= "<a href='#'>下一页</a>";
endPage
= "<a href='#'>末页</a>";
}
else
{
onePage
= "<a href='Default.aspx?pageno=0'>首页</a>";
upPage
= "<a href='Default.aspx?pageno=" + (pageno - 1) + "'>上一页</a>";
nextPage
= "<a href='Default.aspx?pageno=" + (pageno + 1) + "'>下一页</a>";
endPage
= "<a href='Default.aspx?pageno=" + (pagecount - 1) + "'>末页</a>";
}

this.lblOnePage.Text = onePage;
this.lblUpPage.Text = upPage;
this.lblNextPage.Text = nextPage;
this.lblEndPage.Text = endPage;
//if (pageno/10>10)
//{
// for (int i = pageno; i < (pageno - 10); i++)
// {
// this.lblPageNoCount.Text += "<a href='Default.aspx?pageno=" + i + "'>[" + (i + 1) + "]</a>";
// }
//}
//else
//{
// for (int i = pageno; i < (pageno + 10); i++)
// {
// this.lblPageNoCount.Text += "<a href='Default.aspx?pageno=" + i + "'>[" + (i + 1) + "]</a>";
// }
//}
this.gvExhaleInfoManager.DataSource = ExhaleInfoManager.show(pageno, 10,key);
this.gvExhaleInfoManager.DataBind();
}

protected void gvExhaleInfoManager_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(
"onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#999900'");
e.Row.Attributes.Add(
"onmouseout", "this.style.backgroundColor=currentcolor");
}
}

public string selectCNameByCId(object cid)
{
return ClientStateManager.selectCNameByCId(Convert.ToInt32(cid));
}
protected void gvExhaleInfoManager_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
//string eid = this.gvExhaleInfoManager.DataKeys[e.RowIndex]["EId"].ToString();
//Response.Write("<script> window.showModalDialog('ChangeClientState.aspx?eid=1','newwin','dialogHeight: 800px; dialogWidth: 1000px; dialogTop: 800px; dialogLeft: 800px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "<script> window.showModalDialog('ChangeClientState.aspx?eid=" + eid + "','newwin','dialogHeight: 360px; dialogWidth: 150px; dialogTop: 300px; dialogLeft: 600px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;');window.location='Default.aspx'</script>");
// Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "<script>window.open (''ChangeClientState.aspx?eid="+eid+"'', ''newwindow'', ''height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no'') </script>");
}

public string selectUNameByUId(object UId)
{
return UserInfoManager.SelectNameById(Convert.ToInt32(UId));
}

public string selectGroupNameByGId(object GId)
{
return UserGroupManager.selectNameById(Convert.ToInt32(GId));
}


protected void btnSearch_Click(object sender, EventArgs e)
{
if (txtLouPanName.Text == "" && txtStartTime.Text == "" && txtEndTime.Text == "" && txtClientName.Text == "" && txtClientTel.Text == "" && ddlGroupType.SelectedIndex == -1 && ddlUserList.SelectedIndex == -1&&ckListUserState.SelectedIndex==-1)
{
Session[
"ExhaleKey"] = null;
Response.Redirect(
"Default.aspx");
}
else
{
UserInfo u
= Session["USER"] as UserInfo;
StringBuilder s
= new StringBuilder();
if (txtLouPanName.Text != "")
{
string tid = ExhaleInfoManager.ReadTowerIdByTName(txtLouPanName.Text);
s.Append(
" AND TowerId='" + tid + "'");
}
if (txtStartTime.Text != "" && txtEndTime.Text != "")
{
s.Append(
" AND TransitionTime>='" + txtStartTime.Text + "' AND TransitionTime<='" + txtEndTime.Text + "'");
}
if (txtClientName.Text != "")
{
s.Append(
" AND Name LIKE '%" + txtClientName.Text + "%'");
}
if (txtClientTel.Text != "")
{
s.Append(
" AND Tel='" + txtClientTel.Text + "'");
}
if (ckListUserState.SelectedIndex != -1)
{
s.Append(
" AND ");
string x = "";
for (int i = 0; i < ckListUserState.Items.Count; i++)
{
if (ckListUserState.Items[i].Selected == true)
{
x
+= " ClientState=" + Convert.ToInt32(ckListUserState.Items[i].Value) + " OR";
}
}
s.Append(x.Substring(
0, x.LastIndexOf("OR")));
}


//if (ddlGroupType.SelectedIndex != -1)
//{
// s.Append(" AND GroupType=" + Convert.ToInt32(ddlGroupType.SelectedItem.Value) + "");
//}
//if (ddlUserList.SelectedIndex != -1)
//{
// s.Append(" AND UId=" + Convert.ToInt32(ddlUserList.SelectedItem.Value) + "");
//}
string q = " AND UId=" + u.UId + "";
string b = q + " " + s.ToString();
//Response.Write(b);
Session["ExhaleKey"] = b;
gvBind();
// Response.Write(s.ToString());
}
}

public string selectTowerNameByTowerId(object TowerId)
{
return TowerInfoManager.selectTowerNameByTowerId(TowerId.ToString());
}

//public void showgj()
//{
// UserInfo u=Session["USER"] as UserInfo;
// string time = DateTime.Now.ToString("yyyy-M-d HH:00");
// //Response.Write(time);
// int i = FollowUpManager.IfGJ(time, u.UId);
// if (i>0)
// {
// Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>window.open('ShowGJInfo.aspx?count=" + i + "&uid=" + u.UId + "&time=" + time + "','newwindow', 'height=400, width=500, top=300, left=600,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');</script>");
// }
//}


}

 

 

 



跟Session超时有关系吗? 刚才分析了一下原因,客户说出现这种错误会在登录系统后约30分钟时候出现,我那个页面恰巧引用用户信息的,UId在User的属性,USER在Session里面存放的,会不会是这种错误呀?

问题补充: /// <summary> /// 查询客户信息 /// </summary> /// <param name="pageno">页码</param> /// <param name="no">显示数量</param> /// <param name="key">搜索条件</param> /// <returns></returns> public static List<ExhaleInfo> show(int pageno,int no,string key) { List<ExhaleInfo> list = new List<ExhaleInfo>(); string sql = string.Format("SELECT TOP {0} * FROM ExhaleInfo WHERE EId NOT IN (SELECT TOP ({1}*{2}) EId FROM ExhaleInfo WHERE 1=1 {3}) {3}", no, pageno, no, key); using (SqlDataReader Reader = DBHelper.GetReader(sql)) { if (!Reader.HasRows) { list = null; } else { while (Reader.Read()) { ExhaleInfo ea = new ExhaleInfo(); ea.TowerId = Reader["TowerId"].ToString(); ea.EId = Convert.ToInt32(Reader["EId"]); ea.Name = Reader["Name"].ToString(); ea.Tel = Reader["Tel"].ToString(); ea.AddRess = Reader["Address"].ToString(); ea.General = Reader["General"].ToString(); ea.TrackConditions = Reader["TrackConditions"].ToString(); ea.ClientState = Convert.ToInt32(Reader["ClientState"]); ea.ResultType = Convert.ToInt32(Reader["ResultType"]); ea.GroupType = Convert.ToInt32(Reader["GroupType"]); ea.TransitionTime = Reader["Trans
xluo的主页 xluo | 初学一级 | 园豆:94
提问于:2010-07-21 16:05
< >
分享
最佳答案
0

未能找到 UId 这个字段,正常情况下是能找到的,只有在一种情况下无法找到:

你的两个以上的线程使用了同一个实例的 SqlDataReader,当多个线程同时调用 GetOrdinal 的时候,第一个调用的线程会首先去获取你的数据表的字段信息,并存入一个 string[] 中,并在随后的字段查找中通过 string[] 构建 Hashtable,这时,第二个线程进入,它发现 string[] 或者 Hashtable已经创建,但是此时第一个线程还在继续向 string[] 中添加字段名称,于是,第二个线程做循环字符串比较,或者通过 Hashtable判断是否存在 UId 时,就有可能找不到,因为所有的字段信息此时并没有加载完成。

由于你后面提到,所有的数据库操作都失败,因此,除了检查你的代码中是否有多线程共用一个SqlDataReader实例外,请检查你的 DBHelper 创建 SqlDataReader 的方式。

收获园豆:200
Launcher | 高人七级 |园豆:45050 | 2010-07-21 20:08
有更好的 DBHelper 创建 SqlDataReader 的方式 吗? 我想应该是那里的问题,而且数据操作方法,我全部用的是静态方法。
xluo | 园豆:94 (初学一级) | 2010-07-22 10:24
@xluo:不知道你的DBHelper是如何写的,我只是推断一种可能导致错误的原因,一般来说,使用下面的方式创建一个SqlDataReader: public static SqlDataReader ExecuteReaderNoParm(SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText) { if (conn.State != ConnectionState.Open) conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; if (trans != null) cmd.Transaction = trans; cmd.CommandText = cmdText; SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleResult); return rdr; }
Launcher | 园豆:45050 (高人七级) | 2010-07-22 12:35
一般调用方式为: SqlConnection conn = new SqlConnection(connString); SqlDataReader rdr = null; try { rdr = SQLHelper.ExecuteReaderNoParm(conn, null, CommandType.Text, SQL_SELECT_ALL); if (rdr.HasRows) { while (rdr.Read()) {} } rdr.Close(); } catch { if (rdr != null) rdr.Close(); throw; }
Launcher | 园豆:45050 (高人七级) | 2010-07-22 12:39
thank you
xluo | 园豆:94 (初学一级) | 2010-07-23 11:54
其他回答(7)
0

   System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +67
   System.Data.SqlClient.SqlDataReader.get_Item(String name) +15
   KaiSheng.CIM.DAL.UserInfoService.Login(String uname, String upwd) in D:\KaiSheng_CIM_System\KaiSheng_CIM_DAL\UserInfoService.cs:201
   KaiSheng.CIM.BLL.UserInfoManager.login(String uname, String upwd) in D:\KaiSheng_CIM_System\KaiSheng_CIM_BLL\UserInfoManager.cs:46

看这边好像是reader导致的,检查下系统里reader是不是每次执行后都关闭了

建议用using:using(SqlDataReader reader=cmd.ExecuteReader())

kyo-yo | 园豆:5587 (大侠五级) | 2010-07-21 16:08
我使用了自动释放的! 给你看代码 List<ExhaleInfo> list = new List<ExhaleInfo>(); string sql = string.Format("SELECT TOP {0} * FROM ExhaleInfo WHERE EId NOT IN (SELECT TOP ({1}*{2}) EId FROM ExhaleInfo WHERE 1=1 {3}) {3}", no, pageno, no, key); using (SqlDataReader Reader = DBHelper.GetReader(sql)) { if (!Reader.HasRows) { list = null; } else { while (Reader.Read()) { ExhaleInfo ea = new ExhaleInfo(); ea.TowerId = Reader["TowerId"].ToString(); ea.EId = Convert.ToInt32(Reader["EId"]); ea.Name = Reader["Name"].ToString(); ea.Tel = Reader["Tel"].ToString(); ea.AddRess = Reader["Address"].ToString(); ea.General = Reader["General"].ToString(); ea.TrackConditions = Reader["TrackConditions"].ToString(); ea.ClientState = Convert.ToInt32(Reader["ClientState"]); ea.ResultType = Convert.ToInt32(Reader["ResultType"]); ea.GroupType = Convert.ToInt32(Reader["GroupType"]); ea.TransitionTime = Reader["TransitionTime"].ToString(); ea.GongSiName = Reader["GongSiName"].ToString(); ea.UId = Convert.ToInt32(Reader["UId"]); ea.IfUse = Convert.ToInt32(Reader["IfUse"]); ea.CreateTime = Convert.ToDateTime(Reader["CreateTime"]);
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 16:15
突然发现这个:异常详细信息: System.IndexOutOfRangeException: UId 是不是找不到UId?例如数据库中的Uid不存在
支持(0) 反对(0) kyo-yo | 园豆:5587 (大侠五级) | 2010-07-21 16:19
是不是SqlDataReader的问题,换成datatable读取可以吗?
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 16:31
应该不是SqlDataReader的问题,应该是你们的数据库里的数据有问题,感觉像查到某条数据的时候uid不存在
支持(0) 反对(0) kyo-yo | 园豆:5587 (大侠五级) | 2010-07-21 16:53
那为什么其他页面也都不能访问了?
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:05
为什么会产生那种情况?
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:07
0

上线前做压力测试了没有,查查此异常的原因。

Astar | 园豆:40805 (高人七级) | 2010-07-21 16:12
0

为什么不用微软提交的那个类..

非要自己写,

一看你写的这个就不成熟!

pengxiaoer | 园豆:225 (菜鸟二级) | 2010-07-21 16:25
现在的问题不在那里,是为什么并发量一大 就出现那个错误而且所有页面都不能访问了。重启下服务器就好了
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 16:29
0

你上面贴的代码好象不是重点,把 KaiSheng.CIM.DAL.UserInfoService.Login(String uname, String upwd) 这个方法代码贴上来看看。

luotong | 园豆:4 (初学一级) | 2010-07-21 17:02
错误不是由那里引发的,是因为在其他页面出错了,如果在访问跟数据库关联的页面都会出现错误的!
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:16
0

逻辑有问题吧

Ou lei | 园豆:619 (小虾三级) | 2010-07-21 17:12
请指教
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:16
@xluo:你的逻辑我分析不了,不过我觉得异常信息很奇怪,UID是什么?
支持(0) 反对(0) Ou lei | 园豆:619 (小虾三级) | 2010-07-21 17:18
跟Session超时有关系吗? 刚才分析了一下原因,客户说出现这种错误会在登录系统后约30分钟时候出现,我那个页面恰巧引用用户信息的,UId在User的属性,USER在Session里面存放的,会不会是这种错误呀?
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:35
@xluo:你把你从Session中取值的代码贴一下
支持(0) 反对(0) Ou lei | 园豆:619 (小虾三级) | 2010-07-21 17:37
UserInfo u=Session["USER"] as UserInfo;
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:41
@xluo:IndexOutOfRangeException 这个异常我查了一下,是你在通过索引取值的时候取了空数据导致的,你要查查你的数据库里面的数据
支持(0) 反对(0) Ou lei | 园豆:619 (小虾三级) | 2010-07-21 17:48
@Ou lei:或者是你把这个Uid存储在其他地方时侯会不会丢失了
支持(0) 反对(0) Ou lei | 园豆:619 (小虾三级) | 2010-07-21 17:54
@Ou lei:那为什么取了空数据以后,所有跟数据库关联的页面都出现那个错误,就连登录页面也那样!
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-21 17:58
@xluo:这个涉及到业务逻辑的地方我没看到源码我也解释不了,你的错误信息是什么?
支持(0) 反对(0) Ou lei | 园豆:619 (小虾三级) | 2010-07-21 18:00
@Ou lei:把地址发一下吧,下班了.晚上回去看看
支持(0) 反对(0) Ou lei | 园豆:619 (小虾三级) | 2010-07-21 18:01
0

顶 Galactica

提示的是索引越界。

life++ | 园豆:312 (菜鸟二级) | 2010-07-21 21:33
0

 如果是在用户访问过多的情况下造成的
 貌似和错误提示没什么关系
 建议做做压力测试 还有并发现象

小飞机 | 园豆:205 (菜鸟二级) | 2010-07-22 11:22
好像是线程问题,刚才一个大哥分析的结果:未能找到 UId 这个字段,正常情况下是能找到的,只有在一种情况下无法找到: 你的两个以上的线程使用了同一个实例的 SqlDataReader,当多个线程同时调用 GetOrdinal 的时候,第一个调用的线程会首先去获取你的数据表的字段信息,并存入一个 string[] 中,并在随后的字段查找中通过 string[] 构建 Hashtable,这时,第二个线程进入,它发现 string[] 或者 Hashtable已经创建,但是此时第一个线程还在继续向 string[] 中添加字段名称,于是,第二个线程做循环字符串比较,或者通过 Hashtable判断是否存在 UId 时,就有可能找不到,因为所有的字段信息此时并没有加载完成。 由于你后面提到,所有的数据库操作都失败,因此,除了检查你的代码中是否有多线程共用一个SqlDataReader实例外,请检查你的 DBHelper 创建 SqlDataReader 的方式。
支持(0) 反对(0) xluo | 园豆:94 (初学一级) | 2010-07-22 11:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册