From: J-F Portala on
Hi,
I used to work with CRecordset from MFC (VC++ 6.0) to connect to Mysql
database.(via odbc connector)
I think CRecordset are not easy to manipulate.
- when I open a table, I think that all the table is loaded
- to get a field, you have to get all the line
- I don't know how make select count(*) from table and get result.

Are there other solutions more effciency?
Perhaps I don't use the good tools.

Thank for your help
Jeff




From: Giovanni Dicanio on

"J-F Portala" <jfportala(a)free.fr> ha scritto nel messaggio
news:481ed2d9$0$14937$426a74cc(a)news.free.fr...

> I used to work with CRecordset from MFC (VC++ 6.0) to connect to Mysql
> database.(via odbc connector)
> I think CRecordset are not easy to manipulate.
[...]
> Perhaps I don't use the good tools.

Well, CRecordset of MFC in VC++6 is kind of a 10-years-ago technology...

If you want more modern (and easier and more productive) tools for DB
management, you may consider what .NET can offer, for example LINQ and
LINQ-to-SQL.
With it you can write C# code with a SQL-like syntax (SELECT, FROM, WHERE,
etc. ...)

e.g.

<code>

//
// C# code to extract my American friends from my contacts database
// - uses LINQ -
//

PersonsDatabaseContext db = new PersonsDatabaseContext();

// americanFriends is a collection of persons
var americanFriends = from p in db.Persons
where p.State == "USA"
select p;

</code>

There are lots of information about LINQ and LINQ-to-SQL on the web...

Giovanni




From: Paul S. Ganney on
You are correct that opening a table retrieves the whole table. It's
therefore worth setting a query beforehand to prevent this.
e.g. myTable.m_strFilter="[id]=1";

By default you do get the whole record. However, that's because all
the fields have been bound in ClassWizard. If there are fields you
don't ever want, you can unbind them. You can also create several
recordsets on the same table, each to do a different job (this also
allows you to be looking at/manipulating more than one record
simultaneously).

select count(*) is interesting. Take a look at my Code Project class
(http://www.codeproject.com/KB/database/CountSet.aspx) for a way to do
this - which may also give you some other ideas on how to manipulate
the class.

Hope that helps.

Paul.
From: J-F Portala on
Thank you for your help

Jeff