dbTalk Databases Forums  

how to fetch a row?

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss how to fetch a row? in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ZeeGeek
 
Posts: n/a

Default how to fetch a row? - 08-15-2005 , 11:00 AM






------=_Part_13_28441577.1124121593502
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I've tried to fetch a row from a table using mysqlpp::Query::use(const char=
=20
*str) method, but all I got when I printed out row["item"] were all the=20
same, a single letter t. then I tried to print the mysqlpp::ResUse out and=
=20
it was always 1. What's wrong?

--=20
Dell Inspiron 600m
Pentium-M 1.6G
512MB, 60G
ATI 9000 Mobility

------=_Part_13_28441577.1124121593502--

Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: how to fetch a row? - 08-15-2005 , 11:25 AM






ZeeGeek wrote:
Quote:
I've tried to fetch a row from a table using mysqlpp::Query::use(const char
*str) method, but all I got when I printed out row["item"] were all the
same, a single letter t.
Study the simple2 and usequery examples in the v2.0 distribution.

If that isn't enlightening, distill your problem to a small piece of
code that works against the sample database, and post that.

Quote:
then I tried to print the mysqlpp::ResUse out and
it was always 1.
That's normal. You're just printing the value of ResUse:perator
bool() here. If you want it to print the contents of the result set,
I'm open to patches for that. For ideas of how to go about it, and some
idea of the proper scope of this change, see the svn version of the
Wishlist.


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: how to fetch a row? - 08-16-2005 , 01:09 PM



ZeeGeek wrote:
Quote:
mysqlpp::Connection con(false);
con.connect("mysql_cpp_data", "localhost", "test", "test");
mysqlpp::Query query = con.query();
query << "select * from stock";
mysqlpp::ResUse res = query.use();
mysqlpp::Row row;
while (row = res.fetch_row()) {
std::cout << row["item"] << std::endl;
}
I replaced the code in usequery's try block with your code, and it
produced just what I expected it to. Try that, and rebuild the examples
within the MySQL++ tree.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
ZeeGeek
 
Posts: n/a

Default Re: how to fetch a row? - 08-16-2005 , 09:17 PM



On 8/17/05, Warren Young <mysqlpp (AT) etr-usa (DOT) com> wrote:
Quote:
ZeeGeek wrote:

mysqlpp::Connection con(false);
con.connect("mysql_cpp_data", "localhost", "test", "test");
mysqlpp::Query query =3D con.query();
query << "select * from stock";
mysqlpp::ResUse res =3D query.use();
mysqlpp::Row row;
while (row =3D res.fetch_row()) {
std::cout << row["item"] << std::endl;
}
=20
I replaced the code in usequery's try block with your code, and it
produced just what I expected it to. Try that, and rebuild the examples
within the MySQL++ tree.
it worked in usequery, then I updated the current mysql++-1.7.40 to
mysql++-2.0.0 and recompiled my program, it worked! thank you for your
patience, Warren.
=20
Quote:
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu... gmail (DOT) =
com
=20
=20


--=20
Dell Inspiron 600m
Pentium-M 1.6G
512MB, 60G
ATI 9000 Mobility

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.