Click here to Skip to main content
15,867,771 members
Articles / Database Development / SQL Server
Article

C++ wrapper for Sybase's OPENCLIENT Interface

Rate me:
Please Sign up or sign in to vote.
2.33/5 (5 votes)
27 Sep 2002 54K   585   16   6
This article will provide a cross platform C++ wrapper for Sybase's OPENCLIENT interface.

Introduction

With this C++ wrapper, you can easily do the following:

  • Connect/disconnect to a Sybase server;
  • Execute SQL select/insert/update/delete commands;
  • Store the query result in a simple linked list;

This project is a cross platform implementation.

class  ObList ;
class  Record ;
class  RecordSet;
int Connect();
int Connect(char *user, char *pass, char *service);
void DisConnect();
int ExecCommand(char* cmdbuf);

Examples:

#include <stdio.h>
#include "dbclient.h"

int main(int argc, char* argv[])
{
    Connect("sybase11","sa","");
    RecordSet set;
    set.Open("select * from EMP");
    for(int k=0;k<set.GetRecordsCount();k++)
    {
        Record *pRec=set.GetRecord(k);
        for(int l=0;l<pRec->GetFieldsCount();l++)
        {
            printf("%s",pRec->GetFieldValue(l));
            if(l==(pRec->GetFieldsCount()-1))
                printf("\n");
            else
                printf("\t");
        }
    }

    DisConnect();
    return 0;
}

If you are interested in this article, and want to get details, contact me at lihaijian@sina.com or ema13@dongfang-china.com.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
6 years Programer With VC++

Comments and Discussions

 
QuestionWhich is better? Pin
neeraj khan1-Aug-16 14:24
neeraj khan1-Aug-16 14:24 
Questionerror message ????? Pin
seoktaegoon22-Jul-10 1:30
seoktaegoon22-Jul-10 1:30 
Questioni have problem this part? Pin
seoktaegoon22-Jul-10 0:11
seoktaegoon22-Jul-10 0:11 
Generalwhen compile missing lots of .h file Pin
bill chuang2-Sep-04 22:04
bill chuang2-Sep-04 22:04 
The following file missing:

bkpublic ctpublic.h cspublic.h,sqlda.h, tda.h tda_configs.h ......

Can you let me know where can find correct copy to compile ur program


Thanks


bill chuang
GeneralRe: when compile missing lots of .h file Pin
Rohit Joshi22-Sep-04 9:23
Rohit Joshi22-Sep-04 9:23 
GeneralRe: when compile missing lots of .h file Pin
anuradhatp12-Jun-07 7:07
anuradhatp12-Jun-07 7:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.