C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old February 5th, 2002, 11:19 AM
equijada equijada is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Dominican Republic
Posts: 22 equijada User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to equijada
Unhappy C and MySql

I am working in C and I wanna connect my app in C with MySql.
Is there a app library to use with C to connect for mysql?
I had the library for mysql++ but this work more properly with c++ and I am using C?
Any comments?
TIA

Reply With Quote
  #2  
Old February 5th, 2002, 11:42 AM
jonsagara's Avatar
jonsagara jonsagara is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: USA
Posts: 286 jonsagara User rank is Private First Class (20 - 50 Reputation Level)jonsagara User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 m 23 sec
Reputation Power: 7
__________________
Jon Sagara

"Me fail English? That's unpossible!"

Reply With Quote
  #3  
Old March 2nd, 2002, 08:06 AM
oswaldo oswaldo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 1 oswaldo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
try this

URL

Reply With Quote
  #4  
Old March 4th, 2002, 08:09 AM
desmondkenny desmondkenny is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Galway, Ireland
Posts: 4 desmondkenny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
take it from me.....mysql and c are a pain in the ***. there is an api for mysql, though, but there are a few things you might want to know:

/*all this applies to unix*/

to compile, type this:

gcc -g -o -L/*directory*/lib -I/*directory*/include -lmysqlclient -lm

where I put *directory*, put the location of your mysql folder. This should be something like /usr/local/mysql/

then....here are some code snippets you can use:


/*connect to mysql*/
mysql_init(&mysql);
connection = mysql_connect(&mysql, "localhost", "9841860u", "9841860u");

/*check for a connection error*/
if(connection == NULL)
{
/*print error message*/
printf(mysql_error(&mysql));
}


/*select a database*/
mysql_select_db(&mysql, "Nag");

/*here you create a string to pass as a query...you have to do it this way (I think) because you can't pass mysql a variable from C*/
strcpy(query, "SELECT column FROM table WHERE variable = ");
strcat(query, x);
state = mysql_query(connection, query);
if(state != 0)
{
printf(mysql_error(connection));
}

/*this will give you a result set (if you are expecting a result)...you can go through that with row=mysql_fetch_row(result)*/

/*before you can call another query that will return a result set, you must free the result set*/
mysql_free_result(result);

/*close the mysql connection*/
mysql_close(connection);

there are a whole load of functions and structures used, just go through the c api section of the mysql manual.....you can get that online

hope I was of help,

good luck,

Des.


Reply With Quote
  #5  
Old March 18th, 2002, 02:50 AM
patkwong patkwong is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 1 patkwong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to patkwong
how about windows?
how to compile them with bcc?
thx

Reply With Quote
  #6  
Old March 19th, 2002, 06:57 AM
desmondkenny desmondkenny is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Galway, Ireland
Posts: 4 desmondkenny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy

sorry, fate and the universe have conspired to ensure I don't speak windows.

Reply With Quote
  #7  
Old March 19th, 2002, 10:25 AM
patkwong patkwong is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 1 patkwong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to patkwong
god...~
too bad
thx anyway :-)

any others know how to do that?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > C and MySql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway