K
kutiny
Unregistered / Unconfirmed
GUEST, unregistred user!
运行以后会显示出所有记录,但是点击'查询'按钮之后就不显示记录了(只有空值和1会显示所有记录)。<br>请哥哥姐姐,大叔大伯,阿姨婶婶,爷爷奶奶们帮忙看看~~~~~<br>我比较苯,回答请写详细点,谢谢!<br><br>控件属性:<br> Query1: Active True<br> DatabaseName xitong<br> SQL select * from shuju<br> DataSource1: DataSet Query1<br> DBGrid1: DataSource DataSource1<br> ComboBox1: Items ID name sex chusrq 等(虽然表里用的是英文,但是能不能像DBGrid一样改用中文呢?)<br> xitong shuju 表里有 ID name sex chusrq 等字段<br><br>代码:<br>unit Unit2;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ImgList, ComCtrls, ToolWin, StdCtrls, Grids, DBGrids, DB,<br> DBTables, Buttons, ADODB;<br><br>type<br> TForm2 = class(TForm)<br> ToolBar1: TToolBar;<br> ToolButton2: TToolButton;<br> ToolButton1: TToolButton;<br> ImageList1: TImageList;<br> Table1: TTable;<br> DataSource1: TDataSource;<br> DBGrid1: TDBGrid;<br> Query1: TQuery;<br> ComboBox1: TComboBox;<br> Edit1: TEdit;<br> Button1: TButton;<br> ComboBox2: TComboBox;<br> Button2: TButton;<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure ToolButton1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br><br> end;<br><br>var<br> Form2: TForm2;<br><br>implementation<br><br>uses Unit1, Unit3;<br><br>{$R *.dfm}<br><br>procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> Form1.close;<br>end;<br><br><br>procedure TForm2.Button1Click(Sender: TObject);//查询<br>begin<br> with Query1 do<br> begin<br> Close;<br> SQL.Clear;<br> SQL.Add('select * from shuju where ''ComboBox1.Text'' like ''%'+Trim(Edit1.Text)+'%'''); <br> open;<br> end;<br>end;<br><br>procedure TForm2.ToolButton1Click(Sender: TObject);<br>begin<br> Form3.show;<br>end;<br><br>end.<br>不知道这样有没有写清楚