问题描述
未指定的错误说明:执行当前Web请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息:System.Data.OleDb.OleDbException:未指定的错误源错误:行1599:mycommand.Parameters.Add(p3);行1600:mycommand.Parameters.Add(p4);行1601:myconn.Open();行1602:Int32splbsum=0;行1603:if(mycommand.ExecuteScalar()isDBNull)源文件:e:myzwdsiteApp_Codeconn.cs行:1601堆栈跟踪:[OleDbException(0x80004005):未指定的错误]System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionStringconstr,OleDbConnectionconnection)+233System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptionsoptions,ObjectpoolGroupProviderInfo,DbConnectionPoolpool,DbConnectionowningObject)+87System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnectionowningConnection,DbConnectionPoolGrouppoolGroup)+27System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnectionowningConnection)+49System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnectionouterConnection,DbConnectionFactoryconnectionFactory)+89System.Data.OleDb.OleDbConnection.Open()+19conn.out_analyse_cl_dq(Stringcl_dq,Stringsp_lb)ine:myzwdsiteApp_Codeconn.cs:1601out_analyse.LinkButton4_Click(Objectsender,EventArgse)ine:myzwdsiteout_analyse.aspx.cs:132System.Web.UI.WebControls.LinkButton.OnClick(EventArgse)+75System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(StringeventArgument)+98System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(StringeventArgument)+7System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandlersourceControl,StringeventArgument)+11System.Web.UI.Page.RaisePostBackEvent(NameValueCollectionpostData)+172System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint,BooleanincludeStagesAfterAsyncPoint)+4919以下我是程序代码:protectedvoidLinkButton4_Click(objectsender,EventArgse){Panel1.Visible=false;Panel3.Visible=false;Panel2.Visible=true;//表头TableCellbt1=newTableCell();bt1.Width=90;Labellbbt1=newLabel();lbbt1.Text="地区";bt1.Controls.Add(lbbt1);TableCellbt2=newTableCell();Labellbbt2=newLabel();lbbt2.Text="七彩虹主板";bt2.Controls.Add(lbbt2);TableCellbt3=newTableCell();Labellbbt3=newLabel();lbbt3.Text="七彩虹显卡";bt3.Controls.Add(lbbt3);TableCellbt4=newTableCell();Labellbbt4=newLabel();lbbt4.Text="鑫谷电源/机箱套装";bt4.Controls.Add(lbbt4);TableRowtrbt=newTableRow();trbt.Cells.Add(bt1);trbt.Cells.Add(bt2);trbt.Cells.Add(bt3);trbt.Cells.Add(bt4);Table1.Rows.Add(trbt);OleDbConnectionmyconn=conn.myconn();stringstr="select*fromcldq_tab";OleDbCommandmycommand=newOleDbCommand(str,myconn);myconn.Open();OleDbDataReaderdr=mycommand.ExecuteReader();while(dr.Read()){TableCelltc0=newTableCell();Labellbdqname=newLabel();lbdqname.Text=dr["cldq_name"].ToString();tc0.Controls.Add(lbdqname);TableRowtr=newTableRow();//主板统计TableCelltc=newTableCell();Labellbzbnum=newLabel();lbzbnum.Text=(conn.out_analyse_cl_dq(dr["cldq_bh"].ToString(),"zb")).ToString();tc.Controls.Add(lbzbnum);//显卡统计TableCelltc1=newTableCell();Labellbxknum=newLabel();lbxknum.Text=(conn.out_analyse_cl_dq(Convert.ToString(dr["cldq_bh"]),"xk")).ToString();tc1.Controls.Add(lbxknum);//电源统计TableCelltc2=newTableCell();Labellbdynum=newLabel();lbdynum.Text=(conn.out_analyse_cl_dq(Convert.ToString(dr["cldq_bh"]),"dy")).ToString();tc2.Controls.Add(lbdynum);tr.Cells.Add(tc0);tr.Cells.Add(tc);tr.Cells.Add(tc1);tr.Cells.Add(tc2);Table1.Rows.Add(tr);}myconn.Close();}publicstaticInt32out_analyse_cl_dq(stringcl_dq,stringsp_lb){//出库地区按商品类别统计OleDbConnectionmyconn=conn.myconn();OleDbCommandmycommand=newOleDbCommand("selectsum(ot_num)assplbsumfromout_bill_detaill_dispwheresp_lb=@p1andot_date>=@p2andot_date<=@p3andcl_dq=@p4",myconn);OleDbParameterp1=newOleDbParameter("@p1",OleDbType.Char,20);OleDbParameterp2=newOleDbParameter("@p2",OleDbType.Date);OleDbParameterp3=newOleDbParameter("@p3",OleDbType.Date);OleDbParameterp4=newOleDbParameter("@p4",OleDbType.Char,10);p4.Value=cl_dq;p1.Value=sp_lb;stringkk;DateTimemonty1;kk=Convert.ToString(DateTime.Now.Year)+"-"+Convert.ToString(DateTime.Now.Month)+"-"+"01";monty1=Convert.ToDateTime(kk);p2.Value=monty1;p3.Value=DateTime.Now.AddDays(DateTime.DaysInMonth(DateTime.Now.Year,DateTime.Now.Month)-DateTime.Now.Day);mycommand.Parameters.Add(p1);mycommand.Parameters.Add(p2);mycommand.Parameters.Add(p3);mycommand.Parameters.Add(p4);myconn.Open();Int32splbsum=0;if(mycommand.ExecuteScalar()isDBNull){splbsum=0;}else{splbsum=Convert.ToInt32(mycommand.ExecuteScalar());}returnsplbsum;myconn.Dispose();myconn.Close();}
解决方案
解决方案二:
连接数据库的问题吧
解决方案三:
检查out_analyse.aspx.cs这个页面吧
解决方案四:
都检查好几次了,问题依就,第一次运行可以成功,如果再运行,就出现上面的问题了
解决方案五:
这问题,好像没人解决吗?
解决方案六:
先close,再dispose试试