c语言fetch 数据库
SQLHENV henv = SQL_NULL_HENV; SQLHDBC hdbc1 = SQL_NULL_HDBC;
SQLHSTMT hstmt1 = SQL_NULL_HSTMT;
RETCODE retcode;
UCHAR szDSN[SQL_MAX_DSN_LENGTH+1] = "myde",
szUID[MAXNAME] = "sa",
szAuthStr[MAXNAME] = "123456";
UCHAR sql[42] = "select * from SC where Cno = 1";
retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv);
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3,
SQL_IS_INTEGER);
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1);
retcode = SQLConnect(hdbc1, (SQLCHAR*) szDSN, SQL_NTS, (SQLCHAR*)szUID, SQL_NTS, (SQLCHAR*)szAuthStr, SQL_NTS);
if(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
printf("connnect access ok!\n");
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc1, &hstmt1);
printf("%d",retcode);
retcode = SQLExecDirect (hstmt1,sql,30);
printf("%d",retcode); //retcode == -1问题出在这
SQLBindCol(hstmt1, 1, SQL_C_CHAR , list, 5, 0);
do{
retcode = SQLFetch(hstmt1);
printf("%d\n",retcode);
if(retcode != 0){
break;
}
printf("%s/n",list);
}while(1);
}
数据库已经连接 但是数据不能fetch 标注位置开始返回值出错,别的地方的代码有对数据库名的描述 这个程序没有 请问各位大神问题出在哪儿?