数据库表数据显示到listbox的问题delphi
显示在combobox1和combobox2的代码已经写完(没问题就不列出了)按确定按钮显示在listbox1和listbox2的代码如下procedureTForm1....
显示在combobox1和combobox2的代码已经写完(没问题就不列出了)
按确定按钮显示在listbox1和listbox2的代码如下
procedure TForm1.Button1Click(Sender: TObject);
var i : integer;
flag : boolean;
begin
with data_M.ADO_bj do
begin
close;
sql.Clear;
sql.Add('select bjdm from bjsz where bjmc='''+bj.Text+'''');
open;
end;
with data_M.ADO_sjd do
begin
close;
sql.Clear;
sql.Add('select sjdm from sjdb where sjd='''+sjd.Text+'''');
open;
end;
with data_M.ADO_gbkm do
begin
close;
sql.Clear;
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm');
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
open;
end;
listbox2.Clear;
while not data_m.ADO_gbkm.Eof do
begin
listbox2.Items.add(data_m.ADO_gbkm.FieldValues['kmmc']);
data_m.ADO_gbkm.Next;
end;
with data_M.ADO_km do
begin
close;
sql.Clear;
sql.Add('select kmmc from kskmb');
open;
end;
listbox1.Items.Clear;
while not data_m.ADO_km.Eof do
begin
for i := 0 to listbox2.Items.Count - 1 do
begin
if data_m.ADO_km.FieldByName('kmmc').Value <> listbox2.Items[i] then
begin
listbox1.Items.Add(data_m.ADO_km.FieldValues['kmmc']);
data_m.ADO_km.Next;
end;
end;
end;
end;
问题如下:
with data_M.ADO_gbkm do
begin
close;
sql.Clear;
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm');
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
open;
end;
为什么只要这一步筛选就可以显示出来??
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm'); // 这里的 bjdm =:bjdm and sjdm =:sjdm 是来做什么的
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
//这两步代码什么意思 添加数据??添加到哪里?跟显示数据到listbox有什么关系?
接下来要做的保存是左边的数据往右移动一个数据
比如 大学英语 往右移动到右边的listbox
然后保存到数据数据库中
这步怎么做呢?疑惑
图片在http://wenwen.soso.com/z/q169905457.htm 展开
按确定按钮显示在listbox1和listbox2的代码如下
procedure TForm1.Button1Click(Sender: TObject);
var i : integer;
flag : boolean;
begin
with data_M.ADO_bj do
begin
close;
sql.Clear;
sql.Add('select bjdm from bjsz where bjmc='''+bj.Text+'''');
open;
end;
with data_M.ADO_sjd do
begin
close;
sql.Clear;
sql.Add('select sjdm from sjdb where sjd='''+sjd.Text+'''');
open;
end;
with data_M.ADO_gbkm do
begin
close;
sql.Clear;
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm');
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
open;
end;
listbox2.Clear;
while not data_m.ADO_gbkm.Eof do
begin
listbox2.Items.add(data_m.ADO_gbkm.FieldValues['kmmc']);
data_m.ADO_gbkm.Next;
end;
with data_M.ADO_km do
begin
close;
sql.Clear;
sql.Add('select kmmc from kskmb');
open;
end;
listbox1.Items.Clear;
while not data_m.ADO_km.Eof do
begin
for i := 0 to listbox2.Items.Count - 1 do
begin
if data_m.ADO_km.FieldByName('kmmc').Value <> listbox2.Items[i] then
begin
listbox1.Items.Add(data_m.ADO_km.FieldValues['kmmc']);
data_m.ADO_km.Next;
end;
end;
end;
end;
问题如下:
with data_M.ADO_gbkm do
begin
close;
sql.Clear;
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm');
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
open;
end;
为什么只要这一步筛选就可以显示出来??
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm'); // 这里的 bjdm =:bjdm and sjdm =:sjdm 是来做什么的
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
//这两步代码什么意思 添加数据??添加到哪里?跟显示数据到listbox有什么关系?
接下来要做的保存是左边的数据往右移动一个数据
比如 大学英语 往右移动到右边的listbox
然后保存到数据数据库中
这步怎么做呢?疑惑
图片在http://wenwen.soso.com/z/q169905457.htm 展开
1个回答
展开全部
什么叫只要这一步筛选就可以显示出来??with data_M.ADO_gbkm do
begin
close;
sql.Clear;
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm');
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
open;
end;
这个是指ado连接并打开,
bjdm =:bjdm and sjdm =:sjdm 是指要加进来的参数,
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
这个就是参数,其实就是bjdm= data_m.ADO_bj.FieldValues['bjdm'];
listbox1.Items.Add(data_m.ADO_km.FieldValues['kmmc']);
data_m.ADO_km.Next;
这个才是显示listview
点保存的时候,左边的选择项取出值,然后delete掉,然后右边add
begin
close;
sql.Clear;
sql.Add('select kmmc from gbgxqkmb,kskmb where gbgxqkmb.kmdm=kskmb.kmdm and bjdm =:bjdm and sjdm =:sjdm');
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
open;
end;
这个是指ado连接并打开,
bjdm =:bjdm and sjdm =:sjdm 是指要加进来的参数,
parameters.ParamByName('bjdm').Value := data_m.ADO_bj.FieldValues['bjdm'];
parameters.ParamByName('sjdm').Value := data_m.ADO_sjd.FieldValues['sjdm'];
这个就是参数,其实就是bjdm= data_m.ADO_bj.FieldValues['bjdm'];
listbox1.Items.Add(data_m.ADO_km.FieldValues['kmmc']);
data_m.ADO_km.Next;
这个才是显示listview
点保存的时候,左边的选择项取出值,然后delete掉,然后右边add
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询