Newbie SQL question in builder 6.0

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Newbie SQL question in builder 6.0

Post by ashlar64 » Fri 12 May 2006 12:51

I have a certain number stored in int i.

I want to search a table for all entries in a certain field that match i.
Could someoen show me a quick code snippet on how to do this?

I assume using a TMyQuery component would be the best way? I guess I am a bit confused as to how to mingle the c++ code with a SQL statement.

Thanks!

---Dave

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 12 May 2006 13:33

In your case you should use something like this:

Code: Select all

MyQuery->SQL->Text = "select * from Table1 where Field1 = :pram1";
MyQuery->ParamByName("pram1")->AsInteger = i;
MyQuery->Open();
For more information please read MyDAC help or see MyDAC demos.

Guest

Post by Guest » Tue 16 May 2006 14:45

That worked great!

Thanks again!

Are there actually more Builder examples out there? It seems like only 2 came with the trial version (the other ones are Delphi).

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 17 May 2006 09:07

Unfortunately we don't have more C++Builder examples. But using MyDAC with Delphi and C++Builder is the same except syntax only.

Post Reply