Simple Database Operation Problems Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061219132437221.html
When operating the ACCESS database
If the database is
Table word
Field Name field pass
Read access adds all names to the ComboBox control, and then click the content to display the corresponding PASS content in edit1.text.
1.
With qdate do
Begin
Open;
First;
Repeat
ComboBox. Items. Add (fieldbyname ('name'). asstring );
Next;
Until EOF;
Close;
End;
End;
2. Onchange in ComboBox
With qdate do
Begin
Close;
Qdate. SQL. Clear;
Qdate. SQL = 'slect * from word where [name] = '+ ComboBox. text;
Open;
Edit1.text: = fieldbyname ('pass'). asstring;
Close;
End;
End;
Haha, wrong sentence
Qdate. SQL. Add ('slect * from word where [name] = '+ ComboBox. Text );
Passing ....
Share points with me
Which control should I use ..?
My God, I used adoquery1,
Can you tell me what controls are used by 2nd people?
Or can someone tell me a new method ..! Thanks
But the method is not feasible.
1.
With qdate do
Begin
Open;
First;
Repeat
ComboBox. Items. Add (fieldbyname ('name'). asstring );
Next;
Until EOF;
Close;
End;
End;
The word table is not specified here ?...
I am dizzy. Do I know from word clearly in the SQL statement during adoquery initialization?
Then perform operations on adoquery. If adotable is used, you cannot specify it in name.
Three problems.
1. It is best not to use name as the field name, which is a reserved word of the database. If you want to use it, write [name] in this way.
2. traverse the dataset record and use while to write the following code:
With adodataset do
Begin
If active then active: = false;
Commandtext: = 'select * From word ';
Active: = true;
Combobox1.clear; combobox2.clear;
While (not EOF) Do
Begin
Combobox1.items. Add (fieldbyname ('name'). asstring );
Combobox2.items. Add (fieldbyname ('pass'). asstring );
Next;
End;
Close;
End;
3. to implement your functions, write in the onchange time of combox1:
Edit1.text: = combobox2.items [combobox1.itemindex];
Field name. It seems that the parameter cannot be used?