在界面上獲得六個combobox 1-6組件。
獲取另壹個ADODATEset組件並連接數據庫;
當界面顯示時,加載第壹個框並保存名稱。
程序TForm1。TabSheet2Show(發送方:to object);
定義變量
I,j:word;
開始
ADODATAset。關閉;
ADODATAset。CommandText:=“”;
Adodataset.commandtext: = '從xzqhb中選擇不同的省份';
ADODATAset。開放;
如果ADODATAset。RecordCount & gt那麽0
開始
combobox1。物品。清除;
對於i:=0到ADODATAset。記錄計數-1 do
開始
combobox 1 . items . add(ado dataset . field values['省']);
ADODATAset。接下來;
結束;
結束;
結束;
在combobox1的更新事件中,寫加載城市的代碼。
程序TForm1。ComboBox1Change(發件人:to object);
定義變量
I,j:word;
開始
開始
ADODATAset。關閉;
ADODATAset。CommandText:=“”;
ado dataset . commandtext:= ' Select Distinct from xzqhb where province = ' '+combobox 1 . text+' ' ' ';
ADODATAset。開放;
如果ADODATAset。RecordCount & gt那麽0
開始
combobox2。物品。清除;
對於i:=0到ADODATAset。記錄計數-1 do
開始
combobox 2 . items . add(ado dataset . field values[' city]);
ADODATAset。接下來;
結束;
結束;
結束;
在combobox2的更新事件中,寫入裝貨縣(市)的代碼。
程序TForm1。ComboBox2Change(發送方:to object);
定義變量
I,j:word;
開始
開始
ADODATAset。關閉;
ADODATAset。CommandText:=“”;
Adodataset.commandtext: = '從xzqhb中選擇不同的縣(市),其中Province = ' '+combobox 1 . text+' ',City = ' '+combobox 2 . text++ ' ' ' ';
ADODATAset。開放;
如果ADODATAset。RecordCount & gt那麽0
開始
combobox3。物品。清除;
對於i:=0到ADODATAset。記錄計數-1 do
開始
combobox 3 . items . add(ado dataset . field values[' county(city)']);
ADODATAset。接下來;
結束;
結束;
結束;
其他的框自己寫,註意SQL語句的變化,尤其是where子句。