Simple Database Operation Problems

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.