C++ Builder

Moderators: Lundin
Number of threads: 509
Number of posts: 1146

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Combining C++ with Mysql Posted by kingygy on 8 Jan 2010 at 7:24 AM
Hello,
Im currently having some issues with trying to combine these two not been able to find a guide which im able to follow 100% except one where I managed to construct this code from, though its using outdated libaries etc. No compile errors but i get the dreaded
"First-chance exception at 0x7c812a6b in thiswillworkthistime.exe: 0x000006BA: The RPC server is unavailable."

There is only one record with three entry's(columns) currently in my sql database. Here is the code I am using,
#include <string>
#include <stdio.h>
#include <mysql.h>
#include <iostream>
#define host "localhost"
#define username "root"
#define password NULL
#define database "db"
#define name2 5
#define password2 5
#define id2 5
MYSQL *conn;
int main()
{
std::string result[name2][password2][id2];
conn = mysql_init(NULL);
mysql_real_connect(conn,host,username,password,database,0,NULL,0);
MYSQL_RES *res_set;
MYSQL_ROW row;


mysql_query(conn,"SELECT * FROM users WHERE userid=1");
res_set = mysql_store_result(conn);
std::cout<<res_set;

mysql_close(conn);
std::cin.get();
return 0;
std::cin.get();
}

the std::cout<<res_set; is only outputting "00000000"
Any help with this code or recommended tuorials to try out would be great thanks.

Matt



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.