BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / database / #1130同步于 2007/6/3
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Database机器人发帖

求助!!!

newstar19870
2007/6/3镜像同步2 回复
示例 ODBC 程序,该程序连接到 Adaptive Server Anywhere 示例数据库,然后立即断开了连接。 #include <stdio.h> #include <string.h> #include "ntodbc.h" int main(int argc, char* argv[]) { #define DEPT_NAME_LEN 20 #define STMT_LEN 100 SQLINTEGER cbDeptID = 0, cbDeptName = SQL_NTS, cbManagerID = 0; SQLCHAR deptname[ DEPT_NAME_LEN ]; SQLSMALLINT deptID, managerID; SQLHENV env; SQLHDBC dbc; SQLHSTMT stmt; SQLRETURN retcode; SQLCHAR insertstmt[ STMT_LEN ] = "INSERT INTO department ( dept_id, dept_name, dept_head_id )" "VALUES (?, ?, ?)"; SQLCHAR deletestmt[ STMT_LEN ] = "DELETE FROM department WHERE dept_id = 201"; retcode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env ); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { /* Set the ODBC version environment attribute */ retcode = SQLSetEnvAttr( env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); retcode = SQLAllocHandle( SQL_HANDLE_DBC, env, &dbc ); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { retcode = SQLConnect( dbc, (SQLCHAR*) "ASA 9.0 Sample", SQL_NTS, (SQLCHAR*) "DBA", SQL_NTS, (SQLCHAR*) "SQL", SQL_NTS ); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { retcode = SQLAllocHandle( SQL_HANDLE_STMT, dbc, &stmt ); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { SQLBindParameter( stmt, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &deptID, 0, &cbDeptID); SQLBindParameter( stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, DEPT_NAME_LEN, 0, deptname, 0, &cbDeptName); SQLBindParameter( stmt, 3, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &managerID, 0, &cbManagerID); deptID = 201; strcpy( (char * ) deptname, "Sales East" ); managerID = 902; retcode = SQLExecDirect( stmt, insertstmt, SQL_NTS) ; if( retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO ) { printf( "Department inserted\n" ); } retcode = SQLExecDirect( stmt, deletestmt, SQL_NTS) ; if( retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO ) { printf( "Department deleted\n" ); } } } SQLDisconnect( dbc ); } SQLFreeHandle( SQL_HANDLE_DBC, dbc ); } SQLFreeHandle( SQL_HANDLE_ENV, env ); return 0; } 但是编译的时候显示fatal error C1083: Cannot open include file: 'ntodbc.h': No such file or directory,这是咋回事呢?
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
fbsd机器人#1 · 2007/6/3
不是很清楚么?你把答案都写出来了啊 【 在 newstar19870 (miemie) 的大作中提到: 】 : 示例 ODBC 程序,该程序连接到 Adaptive Server Anywhere 示例数据库,然后立即断开了连接。 : #include <stdio.h> : #include <string.h> : ...................
newstar19870机器人#2 · 2007/6/3
【 在 fbsd 的大作中提到: 】 : 不是很清楚么?你把答案都写出来了啊 怎么解决啊?呵呵