asp.net的疑难杂症.....
最近我用vs.net2003尝试写一个三层机构的项目,我用vs.net2003打开解决方案的时候,cpu为100%居高不下....
但是我用vs.net2003打开另一干项目cpu只有百分之几...
估计是程序编写的不规范所造成的....
我数据库层的类是这样写的,本层其他的类写发与之相似...
请高手分析下.....到底是怎么回事....?
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using mwdoa.Common;
namespace mwdoa.DataAccess
{
public class WorkReports:IDisposable
{
private string strCon;
private SqlConnection cn;
private SqlDataAdapter da;
public WorkReports()
{
strCon=ConfigurationSettings.AppSettings["DSN"];
cn= new SqlConnection(strCon);
da= new SqlDataAdapter();
}
//
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(true);
}
//
protected virtual void Dispose(bool disposing)
{
if(!disposing)
return;
if(da!= null)
{
if(da.SelectCommand!=null)
{
if(da.SelectCommand.Connection!=null)
{
da.SelectCommand.Connection.Dispose();
}
da.SelectCommand.Dispose();
}
da.Dispose();
da=null;
}
}
//添加周报
public bool addWeekReports(int uid,int depid,string bweek,string chayi,string plan,string advices)
{
string mysql="insert into weekreports(uid,Dep_id,B_week,B_chayi,B_plan,B_advice) values('"+uid+"','"+depid+"','"+bweek+"','"+chayi+"','"+plan+"','"+advices+"')";
try
{
SqlCommand cm= new SqlCommand(mysql,cn);
cn.Open();
cm.ExecuteNonQuery();
cn.Close();
return true;
}
catch(SqlException)
{
return false;
}
}
//添加日志
public bool addmyrizhi(int uid,int depid,string title,string content)
{
string mysql="insert into rizhi(r_title,r_content,uid,depid) values('"+title+"','"+content+"','"+uid+"','"+depid+"')";
try
{
SqlCommand cm= new SqlCommand(mysql,cn);
cn.Open();
cm.ExecuteNonQuery();
cn.Close();
return true;
}
catch(SqlException)
{
return false;
}
}
}
}