我仿照MSDN上的例子,例子在:
http://www.microsoft.com/china/msdn/library/webservices/asp.net/objectdatasource.mspx?mfr=true
只不过我用的是ACCESS,我用的是VS2005 Team suit+w2ksp4ProductInfo.cs如下:public class ProductInfo
{
public ProductInfo()
{
//
// TODO: 在此处添加构造函数逻辑
//
string strConn = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + Server.MapPath("~\\App_Data\\test.mdb"); // 错误 应输入}
public static OleDbDataReader GetProducts()
{
OleDbConnection conn=new OleDbConnection(strConn);
conn.Open();
string selStr="select * from Student";
OleDbCommand cmd=new OleDbCommand(selStr,conn);
OleDbDataReader MyRead=new OleDbDataReader(CommandBehavior.CloseConnection);
return MyRead;
}
}
} // 错误 应输入类型、命名空间定义或文件尾
http://www.microsoft.com/china/msdn/library/webservices/asp.net/objectdatasource.mspx?mfr=true
只不过我用的是ACCESS,我用的是VS2005 Team suit+w2ksp4ProductInfo.cs如下:public class ProductInfo
{
public ProductInfo()
{
//
// TODO: 在此处添加构造函数逻辑
//
string strConn = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + Server.MapPath("~\\App_Data\\test.mdb"); // 错误 应输入}
public static OleDbDataReader GetProducts()
{
OleDbConnection conn=new OleDbConnection(strConn);
conn.Open();
string selStr="select * from Student";
OleDbCommand cmd=new OleDbCommand(selStr,conn);
OleDbDataReader MyRead=new OleDbDataReader(CommandBehavior.CloseConnection);
return MyRead;
}
}
} // 错误 应输入类型、命名空间定义或文件尾
{
OleDbConnection conn=new OleDbConnection(strConn);
conn.Open();
string selStr="select * from Student";
OleDbCommand cmd=new OleDbCommand(selStr,conn);
OleDbDataReader MyRead=new OleDbDataReader(CommandBehavior.CloseConnection);
return MyRead;
}这一段移到倒数第二个大括号后面