Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-29-2002, 06:10 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
c++ / mysql?

anyone successfully connect to a mysql database with c++.. i know they have an api out there, but i'm wondering if it is difficult.
sde is offline   Reply With Quote
Old 06-30-2002, 02:49 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
I've never tried C++ and mySQL, but I've tried C++ and Oracle SQL.
It was somethign with a pseudo C++ code, you would run through a precompiler, and the code segment you'd use to connect would be like:
Code:
  exec sql begin declare section;
   /* 
       the username/database/fields/etc 
       which you would use in C++ to connect 
       declared. Ie:
    */
    char *uid = "scott/tiger";
    char  name[NAMELEN];
    int   salary, commission;
    short comm_ind;
  exec sql end declare section;
  exec sql whenever sqlerror goto error;

  exec sql connect :uid;
  exec sql declare c cursor for
    select ename, sal, comm from emp where job = 'SALESMAN'
      order by ename;
  exec sql open c;
  exec sql fetch c into :name, :salary, :commission:comm_ind;
  exec sql close c;
  exec sql rollback release;
  exit(0);

error:
  cout << endl << sqlca.sqlerrm.sqlerrmc << endl;
  exec sql rollback release;
  exit(1);
The precompilation would then exchange all the exec sql [something] with the appropriate C++ calls to the SQL database.

But it would be strange, if there wasn't a way to get C++ programs and mySQL to talk with eachother.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 06-30-2002, 07:55 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
thanks for the logic .. i found the api on mysql.com , .. a little confusing, but im going to experiment with it.

thanks again =)
sde is offline   Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB or C#, or something else Apodysophilia MS Technologies ( ASP, VB, C#, .NET ) 6 10-15-2004 09:48 AM
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:36 AM
and on to mysql .. sde Linux / BSD / OS X 2 01-18-2003 07:39 PM
edit? anon Lounge 10 11-21-2002 03:02 PM


All times are GMT -8. The time now is 11:45 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting