首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

access库怎么使用ObjectDataSource分页 ?

2012-01-05 
access库如何使用ObjectDataSource分页 ??我学access数据,初学ObjectDataSource分页!!startrowindexparame

access库如何使用ObjectDataSource分页 ??
我学access数据,初学ObjectDataSource分页!!startrowindexparamert和maxmunrowsparamert参数设置如下
  public   static   OleDbDataReader   GetUser(int   rowIndex,   int   recordCount)
        {
                conn   =   ControlData.Connstring();
                string   selectString   =   "select   Uid,Name,Password,Rname,RoleId   from   [User]   inner   join   [Role]   on   Role.Rid=User.RoleId ";
                cmd   =   new   OleDbCommand(selectString,   conn);
                conn.Open();
                DataReader   =   cmd.ExecuteReader();
                return   DataReader;
                DataReader.Close();
                DataReader.Dispose();
        }
!!但不知在类方法如何加入上面参数??

试过改为
public   static   OleDbDataReader   GetUser(int   rowIndex,   int   recordCount)
        {
             
//===================================================
                //conn   =   ControlData.Connstring();
                //string   selectString   =   "select   top   @recordCount   *   from   [User]   inner   join   [Role]   on   Role.Rid=User.RoleId   where   Uid   not   in   (select   top   (@rowIndex*recordCount)   Uid   from   [User]   order   by   id   desc)   order   by   id   desc ";

                //OleDbParameter   spRowIndex   =   new   OleDbParameter( "@rowIndex ",OleDbType.Integer,   4);
                //spRowIndex.Direction   =   ParameterDirection.Input;
                //OleDbParameter   spRecordCount   =   new   OleDbParameter( "@recordCount ",   OleDbType.Integer,   4);
                //spRecordCount.Direction   =   ParameterDirection.Input;

                //spRowIndex.Value   =   rowIndex;
                //spRecordCount.Value   =   recordCount;

                //cmd.Parameters.Add(spRowIndex);
                //cmd.Parameters.Add(spRecordCount);
           

                //cmd   =   new   OleDbCommand(selectString,   conn);
                //conn.Open();
                //DataReader   =   cmd.ExecuteReader();
                //return   DataReader;
                //DataReader.Close();
                //DataReader.Dispose();


        }
  //cmd.Parameters.Add(spRowIndex);
    //cmd.Parameters.Add(spRecordCount);没有初始化的错误提示信息??
但不对啊????????


[解决办法]
access和ObjectDataSource有什么关系,好像ObjectDataSource是绑定对象的吧,不是数据库
[解决办法]
If Request.QueryString( "Btid ") Is Nothing Or Request.QueryString( "Btid ") = " " Then
Response.Write( " <script> alert( '页面参数出错! ');location.href= '../default.aspx '> </script> ")
Else
Tid = Int(Request.QueryString( "Btid ").ToString)

Dim Pgds As PagedDataSource = New PagedDataSource
Pgds.DataSource = CreatDataSource(Tid).DefaultView
Pgds.AllowPaging = True
Pgds.PageSize = 5
lblTotalPage.Text = Pgds.PageCount.ToString()
Dim CurrentPage As Integer


If Not Request.QueryString( "Page ") Is Nothing Then
CurrentPage = Convert.ToInt32(Request.QueryString( "Page "))
Else
CurrentPage = 1
End If

Pgds.CurrentPageIndex = CurrentPage - 1
lblCurrentPage.Text = CurrentPage.ToString()

If Not Pgds.IsFirstPage Then
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(CurrentPage - 1) + "&Btid= " + Tid.ToString
Else
Me.lnkPrev.Enabled = False
End If

If Not Pgds.IsLastPage Then
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(CurrentPage + 1) + "&Btid= " + Tid.ToString
Else
Me.lnkNext.Enabled = False
End If

rep_prdt.DataSource = Pgds
rep_prdt.DataBind()

End If
[解决办法]
Public Function CreatDataSource(ByVal Tid As String) As DataTable
Return Prd.GetProductInfoByBigType(Tid)
End Function
------------------------------------------------
以前用VB。NET写的,不知道对你有没帮助
[解决办法]
没用过这东西.不过这东西是个数据源控件.跟access有什么关系?

帮顶一下

热点排行