本文发表在 rolia.net 枫下论坛我有一个business class - DataLayer.cs,内容见下边:
using System;
using System.Data;
using System.Data.OleDb;
using System.Web;
namespace SystemOne.NET
{
public class DataLayer
{
private OleDbConnection getConnection()
{
String cnString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" + Server.MapPath("db1.mdb");
return new OleDbConnection(cnString);
}
public DataLayer()
{
}
public DataView getSites()
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Sites", getConnection());
DataSet ds = new DataSet();
myCommand.Fill(ds, "Sites");
return ds.Tables["Sites"].DefaultView;
}
public DataView getPreferredVendors()
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Site_Trade_Join", getConnection());
DataSet ds = new DataSet();
myCommand.Fill(ds, "Site_Trade_Join");
return ds.Tables["Site_Trade_Join"].DefaultView;
}
}
}
可我编译的时候,出错如下:[C# Error] DataLayer.cs(15): The type or namespace name 'Server' could not be found (are you missing a using directive or an assembly reference?)
我觉得太奇怪了,既然Server 是个built-in object,怎么我的编译器就不认识呢?谢谢高手!!更多精彩文章及讨论,请光临枫下论坛 rolia.net
using System;
using System.Data;
using System.Data.OleDb;
using System.Web;
namespace SystemOne.NET
{
public class DataLayer
{
private OleDbConnection getConnection()
{
String cnString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" + Server.MapPath("db1.mdb");
return new OleDbConnection(cnString);
}
public DataLayer()
{
}
public DataView getSites()
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Sites", getConnection());
DataSet ds = new DataSet();
myCommand.Fill(ds, "Sites");
return ds.Tables["Sites"].DefaultView;
}
public DataView getPreferredVendors()
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Site_Trade_Join", getConnection());
DataSet ds = new DataSet();
myCommand.Fill(ds, "Site_Trade_Join");
return ds.Tables["Site_Trade_Join"].DefaultView;
}
}
}
可我编译的时候,出错如下:[C# Error] DataLayer.cs(15): The type or namespace name 'Server' could not be found (are you missing a using directive or an assembly reference?)
我觉得太奇怪了,既然Server 是个built-in object,怎么我的编译器就不认识呢?谢谢高手!!更多精彩文章及讨论,请光临枫下论坛 rolia.net