用的是C#+ajax做无刷新聊天室,人数三四个的时候,没有什么问题,可是人一超过这个数,程序就出错,应该是出在读取数据的时候,有什么原因会造成这样的情况呢?各位做过聊天室的大佬能不能给说说啊,给点精验,会不会是和汉字的编码有关系?我是每隔1.5秒从mssql数据库中获取一次数据是我的罗辑有问题还是程序有问题呢?
解决方案 »
- 关于输出out问题
- 网站推广的软件原理是什么?
- ASP.NET中留言板中像EXCEL那样显示带表格的数据
- 高手进,单文本框对多字段组合查询的问题,
- 工作机会--初级ASP.NET 网站程序员 深圳
- SHAREPOINT高手请进。
- 简单问题,asp.net中DATAGRID的列名的背景颜色怎么设置?
- 这是套的什么论坛?
- 急!!!很简单的问题....但我实在找不出什么原因..请求大家帮忙..在线等....
- 请问怎么读取注册表某子健的默认值?
- 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件
- showModalDialog对话框中,执行任意服务器控件的事件后,窗口标题变为空,如何处理?
using System.Data;
using System.Configuration;
using System.Collections;
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.Data.SqlClient;public partial class GetOnlineUserList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsPublic Public = new clsPublic(); if (Public.IsLogin())
{
//SqlCommand cmd = new SqlCommand();
//SqlDataReader dr=null;
try
{
int intRID = Convert.ToInt32(Request.QueryString["RID"]);
SqlDataAdapter da = new SqlDataAdapter("Select fdUID,fdUserName,fdLevel From tb_Online Where fdRoomID=" + intRID + " And fdIsKickOut=0 Order By fdLevel Desc,fdLoginTime Asc",clsDatabase.getConn());
DataSet ds = new DataSet();
string strTemp="";
da.Fill(ds,"tbOnlineUser");
da.Dispose();
clsDatabase.CloseDB();
int intOnlineCount=ds.Tables["tbOnlineUser"].Rows.Count;
if(intOnlineCount>0){
for (int i = 0; i < intOnlineCount; i++)
{
int intUID = Convert.ToInt32(ds.Tables["tbOnlineUser"].Rows[i].ItemArray[0]);
string strUName = ds.Tables["tbOnlineUser"].Rows[i].ItemArray[1].ToString();
int intLevel = Convert.ToInt32(ds.Tables["tbOnlineUser"].Rows[i].ItemArray[2]);
switch (intLevel)
{
case 2:
strTemp += "<span id=\"OnlineUser" + intUID + "\" class=\"RedTitle\" onMouseDown=\"UserAction(" + intUID + ",'" + strUName + "');\" title=\"给" + strUName + "发送消息\">" + strUName + "</span>(NJ)<br />";
break;
case 1:
strTemp += "<span id=\"OnlineUser" + intUID + "\" class=\"BlueTitle\" onMouseDown=\"UserAction(" + intUID + ",'" + strUName + "');\" title=\"给" + strUName + "发送消息\">" + strUName + "</span>(DB)<br />";
break;
default:
strTemp += "<span id=\"OnlineUser" + intUID + "\" class=\"BlackTitle\" onMouseDown=\"UserAction(" + intUID + ",'" + strUName + "');\" title=\"给" + strUName + "发送消息\">" + strUName + "</span><br />";
break;
}
}
}
ds.Clear();
ds.Dispose();
Response.Write(strTemp);
}
catch (Exception err)
{
Response.Write("系统提示:获取在线列表时出错"+err.Message+"<br />");
}
finally
{
clsDatabase.CloseDB();
}
}
else
{
Response.Write("系统提示:您尚未登录或登录信息已超时,请重新登录后进入聊天室。<br />");
}
}
}
这是其中获取在线用户的程序代码,也是出错的页面之一
可我并没有读取DataTime类型的数据啊
不要用TRY,看看程序出错在哪行。获取聊天信息时的出错信息:Index was outside the bounds of the array
这个明显的告诉你了,数组越界了啊,最好也不用TRY,看看哪个数组出了问题
------------------
看到底是得到什么值