Find Jobs
Hire Freelancers

c++ sql connection - 3 functions: connect to DB, make query, close DB

$30-50 USD

Cancelled
Posted over 11 years ago

$30-50 USD

Paid on delivery
Hi, I have a function that connects to the DB, makes a query and closes the DB and it works fine. I need to separate it to 3 different functions: 1) open connection and returns a handle to the connection. 2) making the query - getting the connection as parameter and making the query. 3) closing the connection - getting the connection as parameter and closing it. see in Detailed requirements the function i have now. Thanks, Dodly ## Deliverables void test1(long ParamAll1 [14],char *dsnName,char* userID,char* passwd,char* Stable,char* Wsid,int swApp){ SQLHANDLE sqlenvhandle; SQLHANDLE sqlconnectionhandle; SQLHANDLE sqlstatementhandle; SQLRETURN retcode; if(SQL_SUCCESS!=SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &sqlenvhandle)) goto FINISHED; if(SQL_SUCCESS!=SQLSetEnvAttr(sqlenvhandle,SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0)) goto FINISHED; if(SQL_SUCCESS!=SQLAllocHandle(SQL_HANDLE_DBC, sqlenvhandle, &sqlconnectionhandle)) goto FINISHED; SQLCHAR retconstring[1024]; char toConnect[1024]=""; char* temb1Buf; temb1Buf="DRIVER={SQL Server};SERVER="; strcat(toConnect, temb1Buf); strcat(toConnect, Wsid); temb1Buf=";DATABASE="; strcat(toConnect, temb1Buf); strcat(toConnect, dsnName); temb1Buf=";UID="; strcat(toConnect, temb1Buf); strcat(toConnect, userID); temb1Buf=";PWD="; strcat(toConnect, temb1Buf); strcat(toConnect, passwd); temb1Buf=";APP=Generic32"; strcat(toConnect, temb1Buf); cout<<" --> "<<toConnect <<" "<<endl; switch(SQLDriverConnect (sqlconnectionhandle, NULL, (SQLCHAR*)toConnect, SQL_NTS, retconstring, 1024, NULL, SQL_DRIVER_NOPROMPT)){ case SQL_SUCCESS_WITH_INFO: show_error(SQL_HANDLE_DBC, sqlconnectionhandle); break; case SQL_INVALID_HANDLE: case SQL_ERROR: show_error(SQL_HANDLE_DBC, sqlconnectionhandle); goto FINISHED; default: break; } if(SQL_SUCCESS!=SQLAllocHandle(SQL_HANDLE_STMT, sqlconnectionhandle, &sqlstatementhandle)) goto FINISHED; /*char* ContqueryUP=AddContQuery(ParamAll1,Stable) ; if(SQL_SUCCESS!=SQLExecDirect(sqlstatementhandle, (SQLCHAR*) ContqueryUP, SQL_NTS)) { show_error(SQL_HANDLE_STMT, sqlstatementhandle); goto FINISHED; }*/ //send buffer to it /*if (swApp==1) { char* NextqueryUP=AddToQuery6020(ParamAll1,Stable) ; if(SQL_SUCCESS!=SQLExecDirect(sqlstatementhandle, (SQLCHAR*) NextqueryUP, SQL_NTS)) { show_error(SQL_HANDLE_STMT, sqlstatementhandle); goto FINISHED; } } else {*/ SQLVARCHAR COLUMN1[50]; int ret=SQLExecDirect(sqlstatementhandle,(SQLCHAR*)"select count(*) from ivr_t_netuni_app_itd where ApplicationID=0", SQL_NTS ); SQLBindCol(sqlstatementhandle, 1, SQL_C_CHAR, &COLUMN1, sizeof(COLUMN1), NULL ); ret = SQLFetch(sqlstatementhandle); if (retcode != SQL_NO_DATA_FOUND) cout << COLUMN1 ; FINISHED: SQLFreeHandle(SQL_HANDLE_STMT, sqlstatementhandle ); SQLDisconnect(sqlconnectionhandle); SQLFreeHandle(SQL_HANDLE_DBC, sqlconnectionhandle); SQLFreeHandle(SQL_HANDLE_ENV, sqlenvhandle); }
Project ID: 2782709

About the project

12 proposals
Remote project
Active 11 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
12 freelancers are bidding on average $32 USD for this job
User Avatar
See private message.
$40.80 USD in 1 day
4.7 (8 reviews)
3.9
3.9
User Avatar
See private message.
$40.80 USD in 1 day
4.8 (6 reviews)
3.7
3.7
User Avatar
See private message.
$42.50 USD in 1 day
3.5 (4 reviews)
3.6
3.6
User Avatar
See private message.
$18.70 USD in 1 day
5.0 (10 reviews)
3.2
3.2
User Avatar
See private message.
$10 USD in 1 day
5.0 (1 review)
1.3
1.3
User Avatar
See private message.
$42.50 USD in 1 day
5.0 (1 review)
1.3
1.3
User Avatar
See private message.
$25.50 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$34 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$20.40 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$25 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$42.50 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$35.70 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of ISRAEL
Petach Tikva Israel, Israel
5.0
6
Payment method verified
Member since Mar 22, 2012

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.