Find Jobs
Hire Freelancers

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

$30-50 USD

已取消
已发布超过 11 年前

$30-50 USD

货到付款
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); }
项目 ID: 2782709

关于此项目

12提案
远程项目
活跃11 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
12威客以平均价$32 USD来参与此工作竞价
用户头像
See private message.
$40.80 USD 在1天之内
4.7 (8条评论)
3.9
3.9
用户头像
See private message.
$40.80 USD 在1天之内
4.8 (6条评论)
3.7
3.7
用户头像
See private message.
$42.50 USD 在1天之内
3.5 (4条评论)
3.6
3.6
用户头像
See private message.
$18.70 USD 在1天之内
5.0 (10条评论)
3.2
3.2
用户头像
See private message.
$10 USD 在1天之内
5.0 (1条评论)
1.3
1.3
用户头像
See private message.
$42.50 USD 在1天之内
5.0 (1条评论)
1.3
1.3
用户头像
See private message.
$25.50 USD 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$34 USD 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$20.40 USD 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$25 USD 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$42.50 USD 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$35.70 USD 在1天之内
0.0 (0条评论)
0.0
0.0

关于客户

ISRAEL的国旗
Petach Tikva Israel, Israel
5.0
6
付款方式已验证
会员自3月 22, 2012起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。