我仿照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;
        }
}
}                                                   //  错误  应输入类型、命名空间定义或文件尾

解决方案 »

  1.   

    hoho,你把GetProducts函数写到ProductInfo构造函数里面去了。人家已经很明显提醒你了嘛
      

  2.   

    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;
            }这一段移到倒数第二个大括号后面