Tuesday, July 28, 2009

Can u give me code and guidlines to connect a c++ code to an oracle sql at backend?

hello! thanks for u r interest. let the code be simple and eaily understandable.if the content is too large mail it to micman.manoj@yahoo.co.in


Thank u.

Can u give me code and guidlines to connect a c++ code to an oracle sql at backend?
//try this out


#include


#include


#include


#include





EXEC SQL BEGIN DECLARE SECTION;


char *userid="SYSTEM";


char *password="MANAGER";


char db_string[[20]]= "tester";


char db_name[[10]] = "TESTER";





EXEC SQL END DECLARE SECTION;





EXEC SQL DECLARE TESTER database;





int main()


{





char c[[100]];


EXEC SQL CONNECT :userid IDENTIFIED BY :password at :db_name using :db_string;


if (sqlca.sqlcode %26lt; 0) { /* There's an error in connecting. */


fprintf (stderr, "example: cannot connect to Oracle database.n");


exit (-1);





}











//if the above code gives some sort of error try by changing db_string and database name, it wd work fine then.
Reply:You can try downloading the source code for this project. http://www.codeproject.com/database/orac... . It should have good examples of how to connect to oracle.

dogwood

No comments:

Post a Comment