powerbuilder开发的程序,查询功能中,listview中的属性列重复出现

powerbuilder开发的程序,查询功能中,listview中的属性列重复出现,如图

举报|2014-07-17 20:12 ACM狐獴    分类:移动开发  |  浏览 84 次
  移动开发

仓库号,商品号,商品名和商品数量,这四个属性在后面重复出现,但没有数据

下面是“精确查询”按钮代码

int i=1

string s_goodsid,s_goodsname,s_goodsnumber,s_storeid


declare youbiao cursor for  //申明游标把数据库中信息暂存到游标中

select storeid,goodsid,goodsname,goodsnumber

from goods

where storeid=:s_storeid;

s_storeid=trim(sle_1.text)

open youbiao;

fetch youbiao into :s_storeid,:s_goodsid,:s_goodsname,:s_goodsnumber;



lv_1.DeleteItems() 


do while sqlca.sqlcode = 0 


   

tab_1.tabpage_1.lv_1.additem(s_storeid,i)

tab_1.tabpage_1.lv_1.setitem(i,2,s_goodsid)

     tab_1.tabpage_1.lv_1.setitem(i,3,s_goodsname)

tab_1.tabpage_1.lv_1.setitem(i,4,s_goodsnumber)

i=i+1


fetch youbiao into  :s_storeid,:s_goodsid,:s_goodsname,:s_goodsnumber;

loop

close youbiao;

我有更好的答案
2014-07-18 08:34 hy1397471  | 九级  最快回答
首先,你用PB开发,这个查询窗口,用个带RETRIEVE参数的datawindow很简单,也很方便的就实现了,datawindow是PB的精髓,
然后在看你的代码,没有给 listview 标题赋值 问题应该在你新建 listview 的相关设置
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对不起,我在上一个回答犯了一个错误。在 Delphi ListView 控件并不直接支持多显示。如果你想要在 ListView 显示多数据,你可以使用其他控件,比如 TStringGrid 或 TDBGrid。 以下是一个简单的示例代码,演示如何连接数据库并查询表数据到 TStringGrid 显示多: ```delphi uses Data.DB, Data.Win.ADODB, Vcl.Grids; procedure LoadDataToGrid(Grid: TStringGrid); var Connection: TADOConnection; Query: TADOQuery; I, Row: Integer; begin Grid.RowCount := 1; Grid.ColCount := 3; // 设置数 // 创建数据库连接组件 Connection := TADOConnection.Create(nil); try Connection.ConnectionString := 'Provider=SQLOLEDB;Data Source=YourServer;Initial Catalog=YourDatabase;User ID=YourUsername;Password=YourPassword'; Connection.Open; // 创建查询组件 Query := TADOQuery.Create(nil); try Query.Connection := Connection; Query.SQL.Text := 'SELECT * FROM YourTable'; // 执行查询 Query.Open; try // 将查询结果添加到 Grid Row := 1; while not Query.Eof do begin Grid.RowCount := Row + 1; // 增加行数 // 将字段值添加到相应的 Grid.Cells[0, Row] := Query.FieldByName('Column1').AsString; Grid.Cells[1, Row] := Query.FieldByName('Column2').AsString; Grid.Cells[2, Row] := Query.FieldByName('Column3').AsString; // 添加更多... Query.Next; Inc(Row); end; finally Query.Close; end; finally Query.Free; end; finally Connection.Free; end; end; ``` 在上面的代码,你需要替换 `YourServer`、`YourDatabase`、`YourUsername`、`YourPassword` 和 `YourTable` 分别为你的数据库服务器、数据库名称、用户名、密码和表名。你还可以根据需要设置更多的数,并在 `Grid.Cells` 设置相应的索引。 调用 `LoadDataToGrid` 函数并传入要显示数据的 TStringGrid 控件,即可将数据库表的数据加载到 Grid 。 希望这次的回答对你有所帮助!如果你还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值