datagrid数据显示不完全!

icelemon1314 2009-09-27 10:42:59
本人用vb+access做个学生管理系统!今天在录入数据的时候出现了这个问题:

datagrid中显示的数据并没有数据库中的那么多,也就是说有部分数据没有显示出来,在网上找了,都不到怎么回事!

例如表student中有1000条记录,但是在datagrid中可能只显示了600条,还有400条不能显示!请问这是什么问题?

datagrid中没有分页,就是一页,是不是超过一页的限制了,如果要分页的话,那该怎么弄呢?

如还有不明白的,请跟帖......

顺便祝大家国庆Happy!
...全文
654 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
lsftest 2009-09-29
  • 打赏
  • 举报
回复
1.vb6打了sp没有?
2.把datagrid数据源的recordcount debug.print出来看看是多少。
三楼の郎 2009-09-29
  • 打赏
  • 举报
回复
Adodc1.RecordSource = "select MemberID as 学生编号,MemberName as 姓名,Sex as 性别,TelNO as 联系电话,Department as 班级,Pay as 缴费 from MemberTable"
Adodc1.Refresh
Adodc1.MoveLast
Adodc1.MoveFirst

If Adodc1.Recordset.EOF = False Then

试试
Tiger_Zhao 2009-09-29
  • 打赏
  • 举报
回复
a)修改的程序批量更新没有及时 UpdateBatch。
b)或者修改程序启动了事务没有及时递交。
c)读取程序没有进行刷新。
d)或者数据存取有缓冲,读取程序刷新时数据尚未完全写入。
饮水需思源 2009-09-29
  • 打赏
  • 举报
回复
用只读方式打开记录集试试
Tiger_Zhao 2009-09-29
  • 打赏
  • 举报
回复
关掉杀毒程序试试。
icelemon1314 2009-09-29
  • 打赏
  • 举报
回复
问题解决!感谢大家的帮助!

引起这个问题的原因很可能是数据库文件引起的,具体原因还不知道!只要打开数据库文件,打开学生表,然后再关掉数据库。那样程序中datagrid就能显示所有数据!

不知道是不是由于文件名引起的。为了保护好数据库文件,我将数据库文件的后缀该为了dll,这是不是会影响到数据的读写?这个问题还有待研究......

今天就先不结贴....看看大家对这个问题有什么看法没?

再次感谢大家的帮忙!
luofenghen 2009-09-28
  • 打赏
  • 举报
回复

DataSet set1 = new DataSet("dsSource");
DataSet set2 = new DataSet("dsTarget");
adapter1.Fill(set1);
adapter1.FillSchema(set2, SchemaType.Mapped);
DataTable table1 = set1.Tables[0];
DataTable table2 = set2.Tables[0];
int num2 = table1.Rows.Count;
this.intPageCount = (int) Math.Round(Math.Ceiling(((double) num2) / PAGESIZE));
this.ViewState["PageCount"] = this.intPageCount;
for (int num1 = 1; ((((this.intCurPageIndex - 1) * PAGESIZE) + num1) <= num2) & (num1 <= PAGESIZE); num1++)
{
table2.ImportRow(table1.Rows[(((this.intCurPageIndex - 1) * PAGESIZE) + num1) - 1]);
}
this.dgDb.DataSource = table2.DefaultView;
this.dgDb.DataKeyField = "sender";
this.dgDb.DataBind();

以上分页代码出自http://topic.csdn.net/t/20060720/19/4894188.html
由tcx1986编写
icelemon1314 2009-09-28
  • 打赏
  • 举报
回复
回5楼:是用vb6.0! 不能分页.....哦! 谢谢了!

回6楼:数据库中所有记录都不是空的!我没有出所有数据哈!只选了部分!

回7楼:但是为什么在600之前却能显示正常,只有输入到一定数量的时候才会出现这个问题!

abc_2004 2009-09-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 asftrhgjhkjlkttttttt 的回复:]
代码贴出看看,才好判断
[/Quote]
支持1楼,您把代码贴出来,以前是有听说过MSFLEXGRID显示1024的问题,但现在早就没有啦....^_^
Tiger_Zhao 2009-09-28
  • 打赏
  • 举报
回复
是不是数据库记录新增或删除了,程序的表格没有刷新?
zdingyun 2009-09-28
  • 打赏
  • 举报
回复
LZ:检查下,你数据表中的某些字段是否未填写内容?
chinaboyzyq 2009-09-28
  • 打赏
  • 举报
回复
没看懂楼主是在用VB6还是在用VB.net,VB6的datagrid根本就不能分页,它只能折分,只有vb.net的datagrid才能分页

如果是VB6看看你的SQL出库语句是否已经把数据全出库了,比如:sql="select * from iTable",不要跟任何条件语句

如果是vb.net看看你的分页设置是否已经设置正确,并且也看看SQL出库语句是否对......
icelemon1314 2009-09-28
  • 打赏
  • 举报
回复

Private Sub CmdAdd_Click()
Dim MemberID As Integer
Dim txtsql2 As String
Dim msgtext2 As String
txtsql2 = "select max(MemberID)+1 from MemberTable"
Set mrc2 = ExecuteSQL(txtsql2, msgtext2)
If mrc2.Fields(0) <> 0 Then
MemberID = mrc2.Fields(0)
Else
MemberID = 1
End If
mrc2.Close

Dim msgtext As String
If Not CmdAdd.Caption <> "添加学生" Then
CmdAdd.Caption = "更新"
CmdChange.Enabled = False
CmdDel.Enabled = False
TxtNo.Text = MemberID
TxtName.Text = ""
TxtTel.Text = ""
TxtDepartment.Text = ""
Else
If TestText(TxtName.Text) <> True Then
MsgBox "姓名不能为空!", , "提示"
Exit Sub
End If
If TestText(TxtTel.Text) = False Then
MsgBox "联系电话不能为空!", , "提示"
Exit Sub
End If
If TestText(TxtDepartment.Text) = False Then
MsgBox "班级不能为空!", , "提示"
Exit Sub
End If
If TestText(TxtPay.Text) = False Then
MsgBox "缴费不能为空!", , "提示"
Exit Sub
End If

Dim txtsql As String
txtsql = "select MemberID,MemberName,Sex,TelNO,Department,Pay from MemberTable"
Set mrc = ExecuteSQL(txtsql, msgtext)
While (mrc.EOF = False)
If (Trim(mrc.Fields(0)) = Trim(TxtName.Text)) Then
MsgBox "用户名已经存在", vbOKOnly + vbExclamation, "警告"
Exit Sub
TxtName.Text = ""
TxtName.SetFocus
Else
mrc.MoveNext
End If
Wend
mrc.AddNew
mrc.Fields(0) = MemberID
mrc.Fields(1) = Trim(TxtName.Text)
If OptBoy.value = True Then
mrc.Fields(2) = "男"
Else
mrc.Fields(2) = "女"
End If
mrc.Fields(3) = Trim(TxtTel.Text)
mrc.Fields(4) = Trim(TxtDepartment.Text)
mrc.Fields(5) = Trim(TxtPay.Text)
mrc.Update
If MsgBox("添加学生" & TxtName.Text & "成功!", vbOKOnly + vbExclamation, "提示") Then
Adodc1.Refresh
End If
mrc.Close
CmdChange.Enabled = True
CmdDel.Enabled = True
CmdAdd.Caption = "添加学生"
End If
End Sub

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error GoTo b
If flag_change = True Then
If Adodc1.Recordset.EOF = False Then
TxtNo.Text = Adodc1.Recordset.Fields(0)
TxtName.Text = Adodc1.Recordset.Fields(1)
TxtTel.Text = Adodc1.Recordset.Fields(3)
TxtDepartment.Text = Adodc1.Recordset.Fields(4)
TxtPay.Text = Adodc1.Recordset.Fields(5)
If Not Adodc1.Recordset.Fields(2) <> "男" Then
OptBoy.value = True
Else
OptGirl.value = True
End If
End If
End If
b:
End Sub

Private Sub Form_Load()
flag_change = True
If conn = True Then
Adodc1.ConnectionString = SQLconn
ConnectString SQLconn
Else
Adodc1.ConnectionString = ACCESSconn
ConnectString ACCESSconn
End If

Adodc1.RecordSource = "select MemberID as 学生编号,MemberName as 姓名,Sex as 性别,TelNO as 联系电话,Department as 班级,Pay as 缴费 from MemberTable"
Adodc1.Refresh
If Adodc1.Recordset.EOF = False Then
TxtNo.Text = Adodc1.Recordset.Fields(0)
TxtName.Text = Adodc1.Recordset.Fields(1)
TxtTel.Text = Adodc1.Recordset.Fields(3)
TxtDepartment.Text = Adodc1.Recordset.Fields(4)
If Not Adodc1.Recordset.Fields(2) <> "男" Then
OptBoy.value = True
Else
OptGirl.value = True
End If
TxtPay.Text = Adodc1.Recordset.Fields(5)
End If
End Sub


不知道是不是要这些代码!

3楼的分页代码能vb下运行?
孤独剑_LPZ 2009-09-27
  • 打赏
  • 举报
回复
代码贴出看看,才好判断

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧