web校园新闻系统课程设计
此处列举Conn类(数据访问类)中主要函数的源码:
public class Conn
{
Public OleDbConnection Lb_Conn=new OleDbConnection(strConn); public static string strConn
{
get
{
StringBuilder strResult = new StringBuilder();
strResult.Append("Provider = Microsoft.Jet.OLEDB.4.0");
strResult.Append("; ");
strResult.Append("Data Source = ");
strResult.Append(HttpContext.Current.Server.MapPath(".")); strResult.Append("\\");
strResult.Append(ConfigurationSettings.AppSettings["MdbPath"]); return strResult.ToString();
}
}
public OleDbDataReader ExecuteOleDbDataReader(string strSql) {
OleDbCommand cmd=new OleDbCommand(strSql,Lb_Conn) OleDbDataReader rd=cmd.ExecuteReader();
return rd;
}
public DataSet CreateDataSet(string strSql,string tableName) {
OleDbDataAdapter da=new OleDbDataAdapter(strSql,Lb_Conn); DataSet dst=new DataSet();
da.Fill(dst,tableName);
return dst;
}
public int ExecuteSql(string strSql)
{
OleDbCommand cmd2=new OleDbCommand(strSql,Lb_Conn); int result=cmd2.ExecuteNonQuery();
return result;
}
~ 19 ~