| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 538 人关注过本帖
标题:DataGrid显示丢了一条!!!!!!!!!
只看楼主 加入收藏
criser
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2005-9-29
收藏
 问题点数:0 回复次数:2 
DataGrid显示丢了一条!!!!!!!!!
我发现了一个关于DataGrid的问题:
如果一个数据库中的表中有100条记录,将它全部显示在DataGrid控件中只有99条,
具体显示方法采用:
this.sqlDataAdapter1.Fill(this.dataSet11,1,0,"bookinfo");
dataGrid1.SetDataBinding(this.dataSet11,"bookinfo");
依次类推,如果表中只有一条记录,DataGrid中将显示空!
但是如果你实现了查找功能,并在你的程序中查找仍能找到丢失的那一条记录,一般丢失的记录为表中的第一条!
不知道各位有没有遇到这样的问题?

解决方法:
不使用上面的方法,改用:
  Access acc1=new Access();
   DataSet ds1=new DataSet();
   acc1.GetDataSet(str1,ds1);//执行SQL语句str1,返回DataSet数据集,ds1
   this.dataGrid1.DataSource=ds1;
   this.dataGrid1.DataMember=ds1.Tables[0].ToString();
这样数据就会显示出来!
搜索更多相关主题的帖子: DataGrid 
2005-10-08 21:52
criser
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2005-9-29
收藏
得分:0 
str1="select * from [yourtable]";
2005-10-08 21:58
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
收藏
得分:0 
//
   // dataSet11
   //
   this.dataSet11.DataSetName = "DataSet1";
   this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
   // dataGrid1
   //
   this.dataGrid1.DataMember = "Customers";
   this.dataGrid1.DataSource = this.dataSet11;
   this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
   this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
   this.dataGrid1.Location = new System.Drawing.Point(0, 0);
   this.dataGrid1.Name = "dataGrid1";
   this.dataGrid1.Size = new System.Drawing.Size(292, 233);
   this.dataGrid1.TabIndex = 0;
//
   // sqlSelectCommand1
   //
   this. = "SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region," +
    " PostalCode, Country, Phone, Fax FROM Customers";
   this.sqlSelectCommand1.Connection = this.sqlConnection1;

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-10-23 12:08
快速回复:DataGrid显示丢了一条!!!!!!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011459 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved