服务器人数多的时候出现Column XXXX does not belong to table

liudong0001 2014-02-24 04:58:30
服务器人数多的时候出现Column XXXX does not belong to table

代码没问题,

最主要的是全是查询语句出现的,返回是datetable类型

更奇怪的是Column XXXX does not belong to table
这个页面执行的时候压根没有这个表,更别说这个字段
刷新的时候这个页面要不就是出现
Column A does not belong to table1
Column A does not belong to table2
Column b does not belong to table3

还有Internal connection fatal error
does not contain a property with the name
等等

上传服务器,人多了就会出现,刷新1下,出现不一样的报错

Server Error in '/' Application.
--------------------------------------------------------------------------------

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'type'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'type'.


很郁闷啊!!!求大神解决

上传1下DLL,就好啦,过一会又出现这个问题,时好时坏。


代码如下:

public static SqlCommand cmd = null;
public static SqlConnection conn = null;
public static string connstr = Maticsoft.DBUtility.PubConstant.GetConnectionString("connstr");
public SQLHelper()
{ }
#region 建立数据库连接对象
/// <summary>
/// 建立数据库连接
/// </summary>
/// <returns>返回一个数据库的连接SqlConnection对象</returns>
public static SqlConnection init()
{
try
{
conn = new SqlConnection(connstr);
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
}
catch (Exception e)
{
throw new Exception(e.Message.ToString());
}
return conn;
}
#endregion

#region 设置SqlCommand对象
/// <summary>
/// 设置SqlCommand对象
/// </summary>
/// <param name="cmd">SqlCommand对象 </param>
/// <param name="cmdText">命令文本</param>
/// <param name="cmdType">命令类型</param>
/// <param name="cmdParms">参数集合</param>
private static void SetCommand(SqlCommand cmd, string cmdText, CommandType cmdType, SqlParameter[] cmdParms)
{
cmd.Connection = conn;
cmd.CommandText = cmdText;
cmd.CommandType = cmdType;
if (cmdParms != null)
{
cmd.Parameters.AddRange(cmdParms);
}
}
#endregion
#region 执行不带参数sql语句,返回一个DataTable对象
/// <summary>
/// 执行不带参数sql语句,返回一个DataTable对象
/// </summary>
/// <param name="cmdText">相应的sql语句</param>
/// <returns>返回一个DataTable对象</returns>
public static DataTable GetDataTable(string cmdText)
{

SqlDataReader reader;
DataTable dt = new DataTable();
try
{
init();
cmd = new SqlCommand(cmdText, conn);
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dt.Load(reader);
reader.Close();
conn.Close();//---
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
return dt;
}
#endregion

#region 执行带参数的sql语句或存储过程,返回一个DataTable对象
/// <summary>
/// 执行带参数的sql语句或存储过程,返回一个DataTable对象
/// </summary>
/// <param name="cmdText">sql语句或存储过程名</param>
/// <param name="cmdType">命令类型</param>
/// <param name="cmdParms">参数集合</param>
/// <returns>返回一个DataTable对象</returns>
public static DataTable GetDataTable(string cmdText, CommandType cmdType, SqlParameter[] cmdParms)
{
SqlDataReader reader;
DataTable dt = new DataTable();
try
{
init();
cmd = new SqlCommand();
SetCommand(cmd, cmdText, cmdType, cmdParms);
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dt.Load(reader);
reader.Close();
conn.Close();//---
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
return dt;
}
#endregion


大家看看那里有问题吗,谢谢大神门

...全文
483 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanglong_longlong 2015-11-30
  • 打赏
  • 举报
回复
Lock试试。
HaiYang2006 2015-11-27
  • 打赏
  • 举报
回复
部署后运行遇到的 异常:System.ArgumentException: Column '"sl"' does not belong to table ds. 原来的方法: private static decimal[] Jsgs(DataSet ds_c, decimal sumSl, decimal sumJe, decimal dhsl, decimal dhje, string col_1, string col_2) { decimal[] strvalue = new decimal[2]; strvalue[0] = 0; strvalue[1] = 0; if (ds_c != null && ds_c.Tables[0] != null && ds_c.Tables[0].Rows.Count > 0) { foreach (DataRow drr in ds_c.Tables[0].Rows) { decimal sl = decimal.Parse(drr["\"“+col_1+”\""].ToString()); decimal ckj = decimal.Parse(drr["\"“+col_2+”\""].ToString()); sumSl = sumSl + dhsl * sl; sumJe = sumJe + dhsl * sl * ckj; } strvalue[0] = sumSl; strvalue[1] = sumJe; } else { strvalue[0] = sumSl + dhsl; strvalue[1] = sumJe + dhje; } return strvalue; } 后来把: decimal sl = decimal.Parse(drr["\"“+col_1+”\""].ToString()); decimal ckj = decimal.Parse(drr["\"“+col_2+”\""].ToString()); 改成: decimal sl = decimal.Parse(drr["sl"].ToString()); decimal ckj = decimal.Parse(drr["ckj"].ToString()); 再次部署后运行就成功了,不在出现异常
坐口之蛙 2014-02-28
  • 打赏
  • 举报
回复
conn也不要用静态的,用using确保每次数据库连接完关闭连接并销毁资源就可以了
md5e 2014-02-28
  • 打赏
  • 举报
回复
用lock啊
liudong0001 2014-02-27
  • 打赏
  • 举报
回复
已经去掉了啊 // public static SqlCommand cmd = null; public static SqlConnection conn = null; public static string connstr = Maticsoft.DBUtility.PubConstant.GetConnectionString("connstr");
still_melody 2014-02-27
  • 打赏
  • 举报
回复
人家是说让你把static去掉
liudong0001 2014-02-27
  • 打赏
  • 举报
回复
不行啊,把静态cmd变量 放到方法一样,狂刷又出现了 Server Error in '/' Application. -------------------------------------------------------------------------------- DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'type'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'type'. Source Error: Line 105: <tr> Line 106: <td style="text-align: left"> Line 107: <%#Eval("type")%> Line 108: <a href="WriteInfo.aspx?id=<%#Eval("id")%>" target="_blank" title="<%#Eval("title")%>"> Line 109: <%#Eval("title") %></a>
liudong0001 2014-02-27
  • 打赏
  • 举报
回复
服务器20003的 和插入a,b,c列没关系 时好时坏,人少的时候正常 人一多 服务器页面报错乱七八糟,当前页面都没写这sql语句,都能显示出来 那sql语句是别的页面上的,怎么会出现这个页面。 估计是并发问题,同时操作反映不过来。。 方法我都试试,不止我一个人出现这个情况,很多人都是这样,我就郁闷别人怎么解决服务器上这种问题的
Ny-6000 2014-02-27
  • 打赏
  • 举报
回复
系统键壮必不够高啊.
liudong0001 2014-02-27
  • 打赏
  • 举报
回复
已经把cmd定义到方法里了,刚才没看懂你说的意思,又看一遍知道了, 我先测试下 #region 执行带参数的sql语句或存储过程,返回一个DataTable对象 /// <summary> /// 执行带参数的sql语句或存储过程,返回一个DataTable对象 /// </summary> /// <param name="cmdText">sql语句或存储过程名</param> /// <param name="cmdType">命令类型</param> /// <param name="cmdParms">参数集合</param> /// <returns>返回一个DataTable对象</returns> public static DataTable GetDataTable(string cmdText, CommandType cmdType, SqlParameter[] cmdParms) { SqlDataReader reader; DataTable dt = new DataTable(); try { init(); SqlCommand cmd = new SqlCommand(); SetCommand(cmd, cmdText, cmdType, cmdParms); reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); dt.Load(reader); reader.Close(); // conn.Close();//--- } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } return dt; } #endregion
H_Gragon 2014-02-27
  • 打赏
  • 举报
回复
表中不存在A、b、c列,你是不是没有表头就插入行了!
liudong0001 2014-02-27
  • 打赏
  • 举报
回复
不是缓存 cmd确实是静态的 怎么定义好
坐口之蛙 2014-02-25
  • 打赏
  • 举报
回复
把cmd定义在方法里面去
坐口之蛙 2014-02-25
  • 打赏
  • 举报
回复
cmd是静态变量造成的
q1231261 2014-02-25
  • 打赏
  • 举报
回复
看看是不是缓存的关系,我以前也是遇到过。
liudong0001 2014-02-25
  • 打赏
  • 举报
回复
有人没

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧