“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------
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里面存放的,会不会是这种错误呀?
未能找到 UId 这个字段,正常情况下是能找到的,只有在一种情况下无法找到:
你的两个以上的线程使用了同一个实例的 SqlDataReader,当多个线程同时调用 GetOrdinal 的时候,第一个调用的线程会首先去获取你的数据表的字段信息,并存入一个 string[] 中,并在随后的字段查找中通过 string[] 构建 Hashtable,这时,第二个线程进入,它发现 string[] 或者 Hashtable已经创建,但是此时第一个线程还在继续向 string[] 中添加字段名称,于是,第二个线程做循环字符串比较,或者通过 Hashtable判断是否存在 UId 时,就有可能找不到,因为所有的字段信息此时并没有加载完成。
由于你后面提到,所有的数据库操作都失败,因此,除了检查你的代码中是否有多线程共用一个SqlDataReader实例外,请检查你的 DBHelper 创建 SqlDataReader 的方式。
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())
上线前做压力测试了没有,查查此异常的原因。
为什么不用微软提交的那个类..
非要自己写,
一看你写的这个就不成熟!
你上面贴的代码好象不是重点,把 KaiSheng.CIM.DAL.UserInfoService.Login(String uname, String upwd) 这个方法代码贴上来看看。
逻辑有问题吧
如果是在用户访问过多的情况下造成的
貌似和错误提示没什么关系
建议做做压力测试 还有并发现象