麻烦看看C语言利用ODBC连接Access数据库 这里SQLExecDirect怎么不成功
#include "windows.h"#include "sqlext.h"#include "string.h"#include "assert.h"#include "stdio.h"RETCODE retcode;HENV henv;HDBC hdbc;HSTMT hstmt;SWORD wColunmCouter;char* strSQL;void Connect();void Open();void End();int main(){ Connect(); Open(); End(); getchar(); return 0;}void Connect(){ retcode = ::SQLAllocEnv(&henv); assert(retcode == 0); retcode = ::SQLAllocConnect(henv,&hdbc); assert(retcode == 0); retcode = ::SQLConnect(hdbc,(SQLCHAR*)&"ODBCDemo1",SQL_NTS,NULL,0,NULL,0); assert(retcode == 0);}void Open(){ assert(hdbc); strSQL = new char[strlen("select * form Book")]; strcpy(strSQL,"select * form Book"); retcode = ::SQLAllocStmt(hdbc,&hstmt); retcode = ::SQLExecDirect(hstmt,(PUCHAR)strSQL,SQL_NTS); retcode = ::SQLNumResultCols(hstmt,&wColunmCouter); retcode = ::SQLFreeStmt(hstmt,SQL_DROP);}void End(){ ::SQLDisconnect(hdbc); ::SQLFreeConnect(hdbc); ::SQLFreeEnv(henv);}