Find Jobs
Hire Freelancers

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

$30-50 USD

Đã hủy
Đã đăng vào hơn 11 năm trước

$30-50 USD

Thanh toán khi bàn giao
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); }
Mã dự án: 2782709

Về dự án

12 đề xuất
Dự án từ xa
Hoạt động 12 năm trước

Bạn muốn kiếm tiền?

Lợi ích khi chào giá trên Freelancer

Thiết lập ngân sách và thời gian
Nhận thanh toán cho công việc
Phác thảo đề xuất của bạn
Miễn phí đăng ký và cháo giá cho công việc
12 freelancer chào giá trung bình $32 USD cho công việc này
Avatar người dùng
See private message.
$40,80 USD trong 1 ngày
4,7 (8 nhận xét)
3,9
3,9
Avatar người dùng
See private message.
$40,80 USD trong 1 ngày
4,8 (6 nhận xét)
3,7
3,7
Avatar người dùng
See private message.
$42,50 USD trong 1 ngày
3,5 (4 nhận xét)
3,6
3,6
Avatar người dùng
See private message.
$18,70 USD trong 1 ngày
5,0 (10 nhận xét)
3,2
3,2
Avatar người dùng
See private message.
$10 USD trong 1 ngày
5,0 (1 nhận xét)
1,3
1,3
Avatar người dùng
See private message.
$42,50 USD trong 1 ngày
5,0 (1 nhận xét)
1,3
1,3
Avatar người dùng
See private message.
$25,50 USD trong 1 ngày
0,0 (0 nhận xét)
0,0
0,0
Avatar người dùng
See private message.
$34 USD trong 1 ngày
0,0 (0 nhận xét)
0,0
0,0
Avatar người dùng
See private message.
$20,40 USD trong 1 ngày
0,0 (0 nhận xét)
0,0
0,0
Avatar người dùng
See private message.
$25 USD trong 1 ngày
0,0 (0 nhận xét)
0,0
0,0
Avatar người dùng
See private message.
$42,50 USD trong 1 ngày
0,0 (0 nhận xét)
0,0
0,0
Avatar người dùng
See private message.
$35,70 USD trong 1 ngày
0,0 (0 nhận xét)
0,0
0,0

Về khách hàng

Cờ của ISRAEL
Petach Tikva Israel, Israel
5,0
6
Phương thức thanh toán đã xác thực
Thành viên từ thg 3 22, 2012

Xác thực khách hàng

Cảm ơn bạn! Chúng tôi đã gửi email chứa đường link để bạn lấy tín dụng miễn phí.
Đã xảy ra lỗi trong khi gửi email của bạn. Hãy thử lại.
Người Dùng Đã Đăng Ký Tổng Số Việc Đã Đăng
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Đang tải xem trước
Đã cấp quyền truy cập vị trí.
Phiên đăng nhập của bạn đã hết hạn và bạn đã bị đăng xuất. Hãy đăng nhập lại.