//窗体加载
private void userList_Load(object sender, EventArgs e)
{
dgvUser.DataSource = GetUserAll();
} public IList<App_Code.UserInfo> GetUserAll()
{
string sql = "select * from users";
IList<App_Code.UserInfo> userAll = new List<App_Code.UserInfo>();
using (OleDbConnection conn = new OleDbConnection(m_connection))
{
App_Code.UserInfo userInfo = null;
OleDbCommand comm = new OleDbCommand();
comm.CommandText = sql;
comm.Connection = conn;
//打开数据库连接
conn.Open();
//执行查询的语句
OleDbDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
userInfo = new CMSInformation.App_Code.UserInfo();
userInfo.Id= int.Parse(dr["Id"].ToString()); //用户Id
userInfo.UserName = dr["UserName"].ToString();//姓名
userInfo.Sex= dr["Sex"].ToString();//性别
userInfo.Phone= dr["Phone"].ToString();//手机
userInfo.Email = dr["Email"].ToString();//邮箱
userInfo.Address = dr["Address"].ToString();//地址
userInfo.Re = dr["Re"].ToString();//备注
userAll.Add(userInfo);
}
conn.Close();
}
return userAll;
}
private void userList_Load(object sender, EventArgs e)
{
dgvUser.DataSource = GetUserAll();
} public IList<App_Code.UserInfo> GetUserAll()
{
string sql = "select * from users";
IList<App_Code.UserInfo> userAll = new List<App_Code.UserInfo>();
using (OleDbConnection conn = new OleDbConnection(m_connection))
{
App_Code.UserInfo userInfo = null;
OleDbCommand comm = new OleDbCommand();
comm.CommandText = sql;
comm.Connection = conn;
//打开数据库连接
conn.Open();
//执行查询的语句
OleDbDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
userInfo = new CMSInformation.App_Code.UserInfo();
userInfo.Id= int.Parse(dr["Id"].ToString()); //用户Id
userInfo.UserName = dr["UserName"].ToString();//姓名
userInfo.Sex= dr["Sex"].ToString();//性别
userInfo.Phone= dr["Phone"].ToString();//手机
userInfo.Email = dr["Email"].ToString();//邮箱
userInfo.Address = dr["Address"].ToString();//地址
userInfo.Re = dr["Re"].ToString();//备注
userAll.Add(userInfo);
}
conn.Close();
}
return userAll;
}
解决方案 »
- 如何发布网站
- 高分悬赏 .net 2.0角色管理全过程
- ********如何根据客户的选择来播放不同的视频********
- ASP.NET需要上传哪些文件到FTP。HTML必须是index.htm这个文件名为主页的,那么ASP.NET什么名字才是主页?
- 用户控件怎样可以调用webform的事件?
- 水晶报表导出pdf时,登陆失败问题.
- 如何在服务端使用BinaryWrite发出文件、图片流的页面中屏蔽鼠标右键或控制显示区的大小??帮忙up!
- Gridview总行数问题包括分页
- 新手提问,在线等待
- 在ASP.NET中使用Crystal Reports使用出现System.NullReferenceException: Object reference not set to an instance of an object.
- ACSMA值表谁有?
- 乱码!
每页数量:20
当前页码:currentIndex
int count = 20 * currentIndex
sql = "select top 20 * from YourTable where TableID not in (select top )" +count.ToString()+" TableD from YourTable)"顺便说一下:2楼干嘛那么愤慨,你有不回帖的权利,但是没有必要这么说。让人感觉你是老板,楼主是跟你打工的小弟似得没意思。
DataSet ds = new DataSet();
da.Fill(ds, startRecord, PageItem, "Sheet");可以直接分页参见http://dotnet.aspx.cc/article/588a07d9-1864-44c4-87ab-2d327c411229/read.aspx
datagridview 分页