CrazyEngineers
  • Database connectivity using C/C++ Tutorial!!!

    slashfear

    Member

    Updated: Oct 25, 2024
    Views: 3.2K
    Hi CEans,

    I thought of putting this tutorial here in CE, so that it would be useful for other CEans!! Some of you out there would have never heard of this too, "Connecting Database with C++ program???" right, anyways no prob's CE is here to help you out 😉(and enlighten you!!! )

    SO here is the Tutorial for making your C++ program to communicate with what ever database you want..... (ie., Oracle, Sybase, MySQL etc....)
    The Tutorial is broken down from the very basics,

    Before starting the Tutorial I would like to introduce you the following:

    -> Compiler: Code::Blocks IDE with MinGW compiler Download Link: #-Link-Snipped-#

    The reason behind choosing this compiler is simple, Code::Blocks is a cross compiler (It can run on any platform like windows, Linux and Mac and hence called as a cross compiler😁) And it is Free to download. This IDE is specially designed for C and C++ and easy to use.

    -> API: We are going to use SQLAPI++ Download Link: <a href="https://www.sqlapi.com/Download/index.html" target="_blank" rel="nofollow noopener noreferrer">Download | SQLAPI++</a>

    SQLAPI++ is a API ( Application Programming Interface) designed specially for C++ database communication(Nothing but a set of header files), This is the Key for communicating with the database, you have other methods also like Pro*C (comes along with your ORACLE) and other methods too, but I choose this SQLAPI++ because it is easy and makes your work simple (smart way in other terms).

    -> OCCI: Oracle C++ Call Interface Download Link: #-Link-Snipped-#

    OCCI is an interface defined by the database company ORACLE that defines for the C++ programmer a comfortable interface to access the ORACLE database with classes using parameters that are reminiscent of SQL statements. The interface exists for ORACLE 9i and ORACLE 10g. OCCI comes along with your ORACLE but still If you guys don't have it, you can download it from the above link (NOTE: You have to be a member to download that file, Its simple just fill in a forum and you are a member!!!)


    Download and install the above three (If you dont have), Now we are almost ready to start,

    Prior Thing to be done before starting:

    -> Open the code::blocks IDE and go to or click on settings -> compiler and debugger settings (You will now see global compiler settings)

    -> Now click on “Linker settings” in the linker settings click on ADD button and add the following

    If your using windows OS :
    [B]
       C:\SQLAPI\lib\libsqlapiddll.a  
       C:\Program Files\CodeBlocks\MinGW\lib\libuser32.a
       C:\Program Files\CodeBlocks\MinGW\lib\libversion.a
       C:\Program Files\CodeBlocks\MinGW\lib\liboleaut32.a
       C:\Program Files\CodeBlocks\MinGW\lib\libole32.a[/B]
    
    These will be found in your SQLAPI++ (If you have not extracted in C: drive then select the appropriate location and add the mentioned files to linker settings)

    If you using Linux OS:
    [B]
      /home/anandakumar/Desktop/SQLAPI/lib/libsqlapi.so
      /home/anandakumar/Desktop/SQLAPI/lib/libsqlapi.a
      /usr/lib/libcodeblocks.so[/B]
    
    And similarly for MAC OS,

    For those of you who are wondering why we are including these files (library files), Its to Link the C/C++ Program with the SQLAPI++.

    Now we are ready to Go guys......

    First simple Program:

    This program illustrates you how to connect and Disconnect from Database:
    [B]#include <stdio.h>  // for printf
    #include <SQLAPI.h> // main SQLAPI++ header
    int main(int argc, char* argv[])
    {
        SAConnection con; // create connection object
          try
        {
            // connect to database
            // in this example it is Oracle,
            // but can also be Sybase, Informix, DB2
            // SQLServer, InterBase, SQLBase and ODBC
            con.Connect(
                "arvind",     // database name
                "slashfear",   // user name
                "Crazy Engineers",   // password
                SA_Oracle_Client);    //client name
            printf("We are connected!\n");
            // Disconnect is optional
            // autodisconnect will ocur in destructor if needed
            con.Disconnect();
            printf("We are disconnected!\n");
        }
        catch(SAException &x)
        {
            // SAConnection::Rollback()
            // can also throw an exception
            // (if a network error for example),
            // we will be ready
            try
            {
                // on error rollback changes
                con.Rollback();
            }
            catch(SAException &)
            {
            }
            // print error message
            printf("%s\n", (const char*)x.ErrText());
        }
         return 0;
    }
    
    [/B]
    The output of the program is simple as shown below,

    OutPut:

    We are Connected!
    We are Disconnected!
    
    Examining the above Code:

    #include <SQLAPI.h>
    - main header, should be used whenever SQLAPI++ is used.

    SAConnection con
    - To connect to a database you should create a connection object and then connect it., here con is the connection object

    con.Connect( "arvind", "slashfear", "Crazy Engineers", SA_Oracle_Client); - This syntax is used for establishing connection with the database. Here the first value is the name of the database (DNS name), the second value is the user name and the third user name is the password. Then the SA_Oracle_Client is the client name we are going to use (In our example its oracle )

    con.Disconnect – This syntax is used for disconnecting from the database.



    Simple isn't it ;-)!!! That's It we are now able to successfully connected and disconnected from the DATABASE, Now to go one step further..... That's how to execute a SQL query like creating a table and inserting values in the table. This is covered in the next Post.... stay connected;-)


    -Arvind(slashfear)
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • slashfear

    MemberMay 19, 2009

    Hi Guys,

    Ok Now that we know how to Connect and Disconnect from a Database,

    Lets now move on with the execution of the query's, (All the example's are for ORACLE database, for other database use the appropriate query's 😛)

    First lets look into Creating a table (assuming that you have little knowledge in SQL query's :smile😀:

    For creating a table, we use the following query:
    [B]create table arvind (id number, name varchar(10));[/B]
    
    So how to execute this from your C++ program, It is done as follows:

    First establish the connection to the database then, after your con.connect; method you should use cmd.setCommandText method to pass the query's to Database, it is as shown below:
    [B]con.Connect("arvind", "slashfear", "Crazy Engineers", SA_Oracle_Client); 
    cmd.setCommandText("create table arvind (id number, name varchar(10));");
    [/B]
    And then to Execute the query we have to use the following command:
    [B]cmd.Execute();[/B]
    
    SO your Final code will look like this:
    [B]
    con.Connect("arvind", "slashfear", "Crazy Engineers", SA_Oracle_Client); 
    cmd.setCommandText("create table arvind (id number, name varchar(10));");
    cmd.Execute();[/B]
    
    SO this query will create a table named arvind with two column id and name. Similarly we can use the cmd.SetCommandText to execute any SQL query

    The following example shows how to create a table and insert five values into the created table in a single program:
    [B]
    #include <stdio.h>  // for printf
    #include <SQLAPI.h> // main SQLAPI++ header
    int main(int argc, char* argv[])
    {
        SAConnection con; // connection object
        SACommand cmd;    // create command object
        try
        {
            // connect to database (Oracle in our example)
            con.Connect("arvind", "slashfear", "Crazy Engineers", SA_Oracle_Client); 
            // associate a command with connection connection can also be specified in SACommand constructor
            cmd.setConnection(&con);
            // create table
            cmd.setCommandText("create table arvind (id number, name varchar(10));");
            cmd.Execute();
            // insert value
            cmd.setCommandText(
                "Insert into arvind values (1, "Bigie")");
        cmd.setCommandText(
                "Insert into arvind values (2, "ES")");
        cmd.setCommandText(
                "Insert into arvind values (3, "shalini")");
        cmd.setCommandText(
                "Insert into arvind values (4, "godfather")");
        cmd.setCommandText(
                "Insert into arvind values (5, "slashfear")");        
    
            cmd.Execute();
            // commit changes on success
            con.Commit();
            printf("Table created, row inserted!\n");
        }
        catch(SAException &x)
        {
            // SAConnection::Rollback() can also throw an exception (if a network error for example),
            // we will be ready
            try
            {
                // on error rollback changes
                con.Rollback();
            }
            catch(SAException &)
            {
            }
            // print error message
            printf("%s\n", (const char*)x.ErrText());
        } 
        return 0;
    }   [/B]
    
    
    As we know Oracle is not auto committed so, we have to commit it!! (committing is nothing but making permanent reflection of data's in the Database, so for doing that we have to use the following command,
    [B]con.Commit();[/B]
    
    and similarly we can roll back the transactions when an exception occurs, so to do that we use,
    [B]con.Rollback();[/B]
    
    For deleting a row we use this command,
    [B]cmd.setCommandText("delete from arvind where id= 5");[/B]
    
    And you can execute any query like stored procedures, triggers what ever you want from C++ programs....

    So guys we are done with the Tutorial!!! and If you have any doubts or questions feel free to post it across.......;-)

    By the way Thanks for reading!!! 😁

    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberMay 19, 2009

    Hi guys,

    You will have demo programs along with the SQLAPI++ setup file, like how to use BLOB etc.... Make sure you go through them too!!!;-)



    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • pradeep_agrawal

    MemberMay 19, 2009

    Its good to see a article on a topic that many C/C++ programmer usually does not know about. Thanks for writing this article Slashfear.

    slashfear
    For those of you who are wondering why we are including these files, Its to recognize the header files and methods we are going to use in the program (To make it simple, we include them so that we can use the methods defined in those files)
    These files are the library files and and not the headers. We need to mention these files so that after compilation, the code where the SQLAPI++ API's are called can be linked with the actual executable code. Correct me if i am wrong.

    slashfear
    If you have any doubts or questions feel free to post it across.......
    An interesting item to see here with be:
    1. When is set some 'select' query as the command and execute, in what form do i get the result and how do i display each entry.
    2. Does the API's always throw exception in case of error or do they return some error codes in specific cases? If it support error codes than could you please list done some of the common codes that may be regularly used.

    -Pradeep
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberMay 19, 2009

    Hi Pradeep,

    These files are the library files and and not the headers. We need to mention these files so that after compilation, the code where the SQLAPI++ API's are called can be linked with the actual executable code. Correct me if i am wrong.
    I dint mention that those files are header files !!!! I just mentioned that those files (Library files) should be included so that, the header files (like #include<SQLAPI.h>and methods (like cmd.Execute, SA_connection) can be recognized by the compiler. I dint mention it as Header file buddy.....😉


    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberMay 19, 2009

    An interesting item to see here with be:
    1. When is set some 'select' query as the command and execute, in what form do i get the result and how do i display each entry.
    2. Does the API's always throw exception in case of error or do they return some error codes in specific cases? If it support error codes than could you please list done some of the common codes that may be regularly used.

    -Pradeep
    Hi Again buddy,

    Regarding your doubts......

    1) You will Get the output in the console as you get output for all C/C++ Programs

    2) Yes the Exception handling mechanism is allowed in SQLAPI++ , The errors which occur in the database will be captured by your exception handling mechanism (that's through try , catch block) and would be displayed in the console if something goes wrong.



    catch(SAException &x)
    {
    // SAConnection::Rollback() can also throw an exception (if a network error for example),
    // we will be ready
    try
    {
    // on error rollback changes
    con.Rollback();
    }
    catch(SAException &)
    {
    }
    // print error message
    printf("%s\n", (const char*)x.ErrText());
    }

    The above code is used to handle Exceptions, and this code as shown below:
      [I][FONT=Book Antiqua, serif]printf("%s\n", (const char*)x.ErrText());[/FONT][/I]
     
    is used to catch and display the error......


    Hope your doubt is cleared......😉 , if you got any more doubts ask dude!!!

    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • pradeep_agrawal

    MemberMay 19, 2009

    slashfear
    I just mentioned that those files (Library files) should be included so that, the header files (like #include<SQLAPI.h> and methods (like cmd.Execute, SA_connection) can be recognized by the compiler.
    That's what my point is, why you need to include the lib files for recognizing header files?

    You are specifying command "#include<SQLAPI.h>" and if the compiler gets the corresponding file in path, it will include it or will throw an error.

    And you don't need lib files to recognize the methods, they are checked against the definition present in the header file you have specified.

    The lib files are required to link your code with the SQL API code present in the lib.

    -Pradeep
    Are you sure? This action cannot be undone.
    Cancel
  • pradeep_agrawal

    MemberMay 19, 2009

    slashfear
    You will Get the output in the console as you get output for all C/C++ Programs
    Is there some way through which i can get the output of select query in some object instead of command line?

    slashfear
    Yes the Exception handling mechanism is allowed in SQLAPI++
    From the examples you had given earlier i got that it throws exceptions. My query was instead of throwing exceptions, are there any cases where the API's return some error code?

    -Pradeep
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberMay 19, 2009

    pradeep_agrawal
    That was my point, why you need to include specify the lib files for recognizing header files?

    You are specifying command "#include<SQLAPI.h>" and if the compiler gets the corresponding file in path, it will include it or will throw an error.

    And you don't need lib files to recognize the methods, they are checked against the definition present in the header file you have specified.

    The lib files are required to link your code with the SQL API code present in the lib.

    -Pradeep

    Exactly methods are checked in your header files and then Library are used to link the program to SQLAPI++ dude !!!

    Thanks I will change it !!!

    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberMay 19, 2009

    Hi Pradeep,

    1) I have Not experimented it still but you can try and Let me know (I will also try that😉)


    2) It would throw exceptions for sure !!!


    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • SzuwarJr

    MemberJun 18, 2009

    Hi,
    Nice tutorial...
    I have to do application in Visual Studio 2008...
    Do You know what I have to do???

    I have also another questions:
    1. Why "main" have parameters, what it represents???
    2. If "try" and "catch" mandotory???
    3. Can i write just:
    void main()
    {
    SAConnection con;
    con.Connect("whatever");
    con.Disconnect();
    }

    PS: Application in CodeBlocks works fine...
    PS2: sorry for my english... xD

    EDIT: I already solve this problem... xD
    Are you sure? This action cannot be undone.
    Cancel
  • HEART-HACKER

    MemberJul 7, 2009

    Can you explain same thing about C# and SQL connectivity ?
    Are you sure? This action cannot be undone.
    Cancel
  • CEMember

    MemberJul 7, 2009

    HEART-HACKER
    Can you explain same thing about C# and SQL connectivity ?
    Hi HEART-HACKER

    Not sure about him whether he can explain or not but by that time you can check MSDN's site. There is lot of related stuff for you. An example is #-Link-Snipped-#

    @Mods Please check if any illegal link shared.

    Thanks !
    Are you sure? This action cannot be undone.
    Cancel
  • golucki

    MemberAug 15, 2009

    Hi,

    Can you please explain how i can use SQLAPI++ to connect to sql compact edition 3.5 database. With SQL CE database file, the file has a password, we do not have any user name as such.

    Thanks,
    Ganesh

    slashfear
    Hi CEans,

    I thought of putting this tutorial here in CE, so that it would be useful for other CEans!! Some of you out there would have never heard of this too, "Connecting Database with C++ program???" right, anyways no prob's CE is here to help you out 😉(and enlighten you!!! )

    SO here is the Tutorial for making your C++ program to communicate with what ever database you want..... (ie., Oracle, Sybase, MySQL etc....)
    The Tutorial is broken down from the very basics,

    Before starting the Tutorial I would like to introduce you the following:

    -> Compiler: Code::Blocks IDE with MinGW compiler Download Link: #-Link-Snipped-#

    The reason behind choosing this compiler is simple, Code::Blocks is a cross compiler (It can run on any platform like windows, Linux and Mac and hence called as a cross compiler😁) And it is Free to download. This IDE is specially designed for C and C++ and easy to use.

    -> API: We are going to use SQLAPI++ Download Link: <a href="https://www.sqlapi.com/Download/index.html" target="_blank" rel="nofollow noopener noreferrer">Download | SQLAPI++</a>

    SQLAPI++ is a API ( Application Programming Interface) designed specially for C++ database communication(Nothing but a set of header files), This is the Key for communicating with the database, you have other methods also like Pro*C (comes along with your ORACLE) and other methods too, but I choose this SQLAPI++ because it is easy and makes your work simple (smart way in other terms).

    -> OCCI: Oracle C++ Call Interface Download Link: #-Link-Snipped-#

    OCCI is an interface defined by the database company ORACLE that defines for the C++ programmer a comfortable interface to access the ORACLE database with classes using parameters that are reminiscent of SQL statements. The interface exists for ORACLE 9i and ORACLE 10g. OCCI comes along with your ORACLE but still If you guys don't have it, you can download it from the above link (NOTE: You have to be a member to download that file, Its simple just fill in a forum and you are a member!!!)


    Download and install the above three (If you dont have), Now we are almost ready to start,

    Prior Thing to be done before starting:

    -> Open the code::blocks IDE and go to or click on settings -> compiler and debugger settings (You will now see global compiler settings)

    -> Now click on “Linker settings” in the linker settings click on ADD button and add the following

    If your using windows OS :
    [B]
       C:\SQLAPI\lib\libsqlapiddll.a  
       C:\Program Files\CodeBlocks\MinGW\lib\libuser32.a
       C:\Program Files\CodeBlocks\MinGW\lib\libversion.a
       C:\Program Files\CodeBlocks\MinGW\lib\liboleaut32.a
       C:\Program Files\CodeBlocks\MinGW\lib\libole32.a[/B]
    
    These will be found in your SQLAPI++ (If you have not extracted in C: drive then select the appropriate location and add the mentioned files to linker settings)

    If you using Linux OS:
    [B]
      /home/anandakumar/Desktop/SQLAPI/lib/libsqlapi.so
      /home/anandakumar/Desktop/SQLAPI/lib/libsqlapi.a
      /usr/lib/libcodeblocks.so[/B]
    
    And similarly for MAC OS,

    For those of you who are wondering why we are including these files (library files), Its to Link the C/C++ Program with the SQLAPI++.

    Now we are ready to Go guys......

    First simple Program:

    This program illustrates you how to connect and Disconnect from Database:
    [B]#include <stdio.h>  // for printf
    #include <SQLAPI.h> // main SQLAPI++ header
    int main(int argc, char* argv[])
    {
        SAConnection con; // create connection object
          try
        {
            // connect to database
            // in this example it is Oracle,
            // but can also be Sybase, Informix, DB2
            // SQLServer, InterBase, SQLBase and ODBC
            con.Connect(
                "arvind",     // database name
                "slashfear",   // user name
                "Crazy Engineers",   // password
                SA_Oracle_Client);    //client name
            printf("We are connected!\n");
            // Disconnect is optional
            // autodisconnect will ocur in destructor if needed
            con.Disconnect();
            printf("We are disconnected!\n");
        }
        catch(SAException &x)
        {
            // SAConnection::Rollback()
            // can also throw an exception
            // (if a network error for example),
            // we will be ready
            try
            {
                // on error rollback changes
                con.Rollback();
            }
            catch(SAException &)
            {
            }
            // print error message
            printf("%s\n", (const char*)x.ErrText());
        }
         return 0;
    }
    
    [/B]
    The output of the program is simple as shown below,

    OutPut:

    We are Connected!
    We are Disconnected!
    
    Examining the above Code:

    #include <SQLAPI.h>
    - main header, should be used whenever SQLAPI++ is used.

    SAConnection con
    - To connect to a database you should create a connection object and then connect it., here con is the connection object

    con.Connect( "arvind", "slashfear", "Crazy Engineers", SA_Oracle_Client); - This syntax is used for establishing connection with the database. Here the first value is the name of the database (DNS name), the second value is the user name and the third user name is the password. Then the SA_Oracle_Client is the client name we are going to use (In our example its oracle )

    con.Disconnect – This syntax is used for disconnecting from the database.



    Simple isn't it ;-)!!! That's It we are now able to successfully connected and disconnected from the DATABASE, Now to go one step further..... That's how to execute a SQL query like creating a table and inserting values in the table. This is covered in the next Post.... stay connected;-)


    -Arvind(slashfear)
    Are you sure? This action cannot be undone.
    Cancel
  • vishnu priya

    MemberSep 29, 2009

    Can anybody help with the connectivity of SQL database and VB?
    Are you sure? This action cannot be undone.
    Cancel
  • tnhems

    MemberSep 29, 2009

    I m using CodeBlocks on MAC OS.
    In the linker settings, i added these 2 files:
    /home/<user>/Desktop/SQLAPI/lib/libsqlapi.so
    /home/<user>/Desktop/SQLAPI/lib/libsqlapi.a

    But the third file mentioned is not in Mac os,
    /usr/lib/libcodeblocks.so
    Where can i find it or should i download it seperately???
    Without this file, I m getting the following error:


    Linking console executable: bin/Release/DBConnect
    /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning empty table of contents: /Users/<username>/Desktop/SQLAPI/lib/libsqlapi.a (can't load from it)
    /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: /Users/<username>/Desktop/SQLAPI/lib/libsqlapi.so bad magic number (not a Mach-O file)
    collect2: ld returned 1 exit status


    And can I use the same code in XCode2.5 to connect to the database?If yes how do i add the above files?

    Someone please guide me...
    Are you sure? This action cannot be undone.
    Cancel
  • antonio8a

    MemberDec 7, 2010

    hi, i need to make a software on linux, i using code::blocks but i don't understand that a database with code::blocks, are you help me?
    Are you sure? This action cannot be undone.
    Cancel
  • flipmedia

    MemberJan 25, 2011

    Hi pals,
    I saw your Thread Regarding Connecting with Oracle, But My Requirement is
    to connect my mysql Database table in my local system(Windows Xp,Dev C++) Environment
    to C++. How it can do , pls Reply me

    Thankfully
    Anes P. A :sshhh:
    Are you sure? This action cannot be undone.
    Cancel
  • Navratan

    MemberJan 25, 2011

    seminar

    hey....
    please suggest me for info. tech . seminar topic.....
    jara hatke......
    Are you sure? This action cannot be undone.
    Cancel
  • slashfear

    MemberFeb 7, 2011

    Hi Flipmedia,

    Follow this link: #-Link-Snipped-#

    Which has the pictograph-cal instructions on how to do it.....


    -Arvind


    flipmedia
    Hi pals,
    I saw your Thread Regarding Connecting with Oracle, But My Requirement is
    to connect my mysql Database table in my local system(Windows Xp,Dev C++) Environment
    to C++. How it can do , pls Reply me

    Thankfully
    Anes P. A :sshhh:
    Are you sure? This action cannot be undone.
    Cancel
  • shivang16

    MemberFeb 6, 2012

    Sir thanks for sharing articals vc++ /sqlapi,but sir i am getting error

    Error 1 error LNK2019: unresolved external symbol "public: virtual __thiscall SAConnection::~SAConnection(void)" (??1SAConnection@@UAE@XZ) referenced in function __catch$_main$0 Oratry.obj

    approx 13 error i am getting .
    #include "stdafx.h"


    #include <SQLAPI.h>

    #include <stdio.h>


    int main()
    {
    SAConnection con;
    SACommand cmd;
    try
    {
    con.Connect("", "scott", "tiger", SA_Oracle_Client);
    cmd.setConnection(&con);
    cmd.setCommandText(
    "Create table test_tbl(fid integer, fvarchar20 varchar(20), fblob blob)");
    cmd.Execute();
    cmd.setCommandText(
    "Insert into test_tbl(fid, fvarchar20) values (1, 'Some string (1)')");
    cmd.Execute();
    con.Commit();
    }
    catch(SAException &x)
    {
    try
    {
    con.Rollback();
    }
    catch(SAException &)
    {
    }
    }
    // Enabling Windows XP visual effects before any controls are created


    return 0;
    }


    i ve added all .a lib file in liner setting ..so plz gimme solution for this ineedly needed .

    thanks
    Are you sure? This action cannot be undone.
    Cancel
  • prasad.ram126

    MemberMar 29, 2012

    it is nice
    and if you have any tutorial related to database connectivity using c only
    and using GNU complier please tell me
    Are you sure? This action cannot be undone.
    Cancel
  • Preethi Gowri

    MemberJun 13, 2012

    slashfear
    Hi Flipmedia,

    Follow this link: #-Link-Snipped-#

    Which has the pictograph-cal instructions on how to do it.....


    -Arvind
    guys plz help me out...
    im using codeblock compiler, i followed all the steps which arvind had mentioned previously..
    my problem is after the succesful compilation it says libsqlapid.dll file or directory not found😔 , when i try running the code...
    Are you sure? This action cannot be undone.
    Cancel
  • Sasikumar VK

    MemberJul 11, 2012

    Hi Arvind,
    Thanks for the tutorial..

    I've followed all the procedures mentioned above & pasted your code in Code::Blocks,but it is throwing following errors..

    E:\Can\datac\main.c|2|error: SQLAPI.h: No such file or directory|
    E:\Can\datac\main.c||In function 'main'😐
    E:\Can\datac\main.c|5|error: 'SAConnection' undeclared (first use in this function)|
    E:\Can\datac\main.c|5|error: (Each undeclared identifier is reported only once|
    E:\Can\datac\main.c|5|error: for each function it appears in.)|
    Could you please..guide me to proceed further..
    Thanks in advance..
    Are you sure? This action cannot be undone.
    Cancel
  • Preethi Gowri

    MemberJul 11, 2012

    check the path of your header.. else mention the whole path of your header in the include line, within double codes...
    Are you sure? This action cannot be undone.
    Cancel
  • Sasikumar VK

    MemberJul 27, 2012

    Preethi Gowri
    check the path of your header.. else mention the whole path of your header in the include line, within double codes...
    Tanx Gowri..
    Are you sure? This action cannot be undone.
    Cancel
  • JAI_SINGH

    MemberSep 3, 2012

    Hi I have done this but when I then my cursor gets into "sqlapi.h" file and it starts blinking

    class ISAClient;
    class ISAConnection;
    class ISACursor;

    class SAMutex;

    class SAConnection;
    class SACommand;
    struct sa_Commands;
    class saOptions;
    class SAParam;
    class SAField;

    class SAException;

    class saPlaceHolder;

    class SABytes;
    class SALongBinary;
    class SALongChar;
    class SABLob;
    class SACLob;
    class SAValueRead;
    and shows errors in the above given lines.......
    Are you sure? This action cannot be undone.
    Cancel
  • Akash Agrawal

    MemberMar 2, 2013

    Hi Frnds,

    I am trying to connect VC++ and Oracle10 g.
    But i am getting Error " LNK2019 Unresolved Externals"..

    I am using VS 2008 i.e. VC9.

    I have also tried with VS2012 and MySQL. But Same Error was there.

    Please Help me out in this Problem.

    I have also followed all the steps above but... ;( same Error... " LNK2019 Unresolved Externals" Plz Help ....
    Are you sure? This action cannot be undone.
    Cancel
  • Preethi Gowri

    MemberMar 2, 2013

    check this#-Link-Snipped-# out
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberMar 2, 2013

    Akash Agrawal
    Hi Frnds,

    I am trying to connect VC++ and Oracle10 g.
    But i am getting Error " LNK2019 Unresolved Externals"..

    I am using VS 2008 i.e. VC9.

    I have also tried with VS2012 and MySQL. But Same Error was there.

    Please Help me out in this Problem.

    I have also followed all the steps above but... ;( same Error... " LNK2019 Unresolved Externals" Plz Help ....
    Could be many reasons, maybe you are using some variable without declaring, or you are using some function without including appropriate headerfile, so check ur code!
    and if u still fail, then paste it here, maybe we could help😁
    Good Luck!!!😀
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorMar 14, 2013

    #-Link-Snipped-# - It'd be great to have you back on CE and take this thread forward. Looking forward to your participation again 😀
    Are you sure? This action cannot be undone.
    Cancel
  • DP RWT

    MemberJun 26, 2013

    i want a project on database connectivity programming in c++ or dotnet.so plz solve my problem.
    Are you sure? This action cannot be undone.
    Cancel
  • DP RWT

    MemberJun 26, 2013

    😐
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberJun 29, 2013

    DP RWT
    i want a project on database connectivity programming in c++ or dotnet.so plz solve my problem.
    Are u searching for Ideas? Well if that is the case there can be a lot of projects possible, for example:
    Online Quiz Software, in which u use C++ or C# or VB for GUI creation and for back-end (ie storing databases), any SQL, and connect both to make it work, the choice of language depends on your interest.😀
    Are you sure? This action cannot be undone.
    Cancel
  • Sarthak Sinha

    MemberAug 20, 2015

    can you please explain that once i populate the database...and then how can i extract data and use it in C++...
    Are you sure? This action cannot be undone.
    Cancel
  • Pankaj_malviya5

    MemberJan 11, 2016

    I need a c program that, when given a table name and database name as arguments, will query the informix & postgresql system tables to get all permissions granted to various users on that table. The program will then generate sql statements to grant all these permissions on the table and write these statements to a file which can be run later.(AIX OS Using).
    Are you sure? This action cannot be undone.
    Cancel
  • Sobhita Kumar Sahu

    MemberApr 16, 2016

    Could you please make similar tutorial OCCI.
    Are you sure? This action cannot be undone.
    Cancel
  • Sobhita Kumar Sahu

    MemberApr 16, 2016

    Could you please make similar tutorial on OCCI.
    Are you sure? This action cannot be undone.
    Cancel
  • skobu

    MemberApr 20, 2016

    Hi Guys,
    Just need one confirmation from your side all those who
    have run this database connectivity pgm , I wanted to know have they downloaded #-Link-Snipped-# or #-Link-Snipped-# for SQLAPI++ Library............... . And also while trying to execute
    the program i was getting errors in SQLAPI.h..... was anybody facing the same issue
    Are you sure? This action cannot be undone.
    Cancel
  • Shiva Abhijith

    MemberJul 9, 2018

    5Vwu-IMG-20180709-WA0001.jpeg

    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorJul 10, 2018

    #-Link-Snipped-# - Could you explain the problem you are facing so that we can help? The screenshot doesn't say much.

    Are you sure? This action cannot be undone.
    Cancel
  • Shiva Abhijith

    MemberJul 11, 2018

    I runned the given program and I found those errors(in screenshot).I am unable to proceed as I can't understood those errors.

    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register