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個の提案
リモートプロジェクト
アクティブ 12年前

お金を稼ぎたいですか?

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)
プレビューを読み込み中
位置情報へのアクセスが許可されました。
あなたのログインセッションの有効期限がきれ、ログアウトされました。もう一度ログインしてください。