资源描述:
《在vb中用odbcapi访问数据库》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、一、声明ODBCAPI函数 这些函数都在odbc32.dll中定义了,要在程序中调用这些函数,必须首先对它们进行声明。建立一个模块,在里面写入下列内容:'==声明odbc32.dll中定义的ODBCAPI函数==PublicDeclareFunctionSQLAllocEnvLib"odbc32.dll"(phenv&)AsIntegerPublicDeclareFunctionSQLAllocConnectLib"odbc32.dll"(ByValHenv&,phdbcd&)AsIntegerPublicDeclareFunctio
2、nSQLAllocStmtLib"odbc32.dll"(ByValHdbc&,phstmt&)AsIntegerPublicDeclareFunctionSQLConnectLib"odbc32.dll"(ByValHdbc&,ByValszDSN$,ByValcbDSN%,ByValszUID$,ByValcbUID%,ByValszPWD$,ByValcbPWD%)AsIntegerPublicDeclareFunctionSQLColAttributesLib"odbc32.dll"(ByValHstmt&,ByValicol%,
3、ByValfDescType%,ByValrgbDescAsString,ByValcbDescMax%,pcbDesc%,pfDesc&)AsIntegerPublicDeclareFunctionSQLDisconnectLib"odbc32.dll"(ByValHdbc&)AsIntegerPublicDeclareFunctionSQLExecDirectLib"odbc32.dll"(ByValHstmt&,ByValszSqlStr$,ByValcbSqStr&)AsIntegerPublicDeclareFunctionSQ
4、LFetchLib"odbc32.dll"(ByValHstmt&)AsIntegerPublicDeclareFunctionSQLFreeConnectLib"odbc32.dll"(ByValHdbc&)AsIntegerPublicDeclareFunctionSQLFreeEnvLib"odbc32.dll"(ByValHenv&)AsIntegerPublicDeclareFunctionSQLFreeStmtLib"odbc32.dll"(ByValHstmt&,ByValfOption%)AsIntegerPublicDe
5、clareFunctionSQLGetDataLib"odbc32.dll"(ByValHstmt&,ByValicol%,ByValfCType%,ByValrgbValueAsString,ByValcbValueMax&,pcbValue%)AsIntegerPublicDeclareFunctionSQLNumResultColsLib"odbc32.dll"(ByValHstmt&,pccol%)AsIntegerPublicDeclareFunctionSQLGetDiagRecLib"odbc32.dll"(ByValHan
6、dleType%,ByValHandle&,ByValRecNumber%,Sqlstate%,NativeErrorPtr%,MessageTextAsString,ByValBufferlenchgth%,TextlenchgthPtr%)数据库访问常量和数据源信息常量:'数据库访问常量PublicConstSQL_C_CHARAsLong=1PublicConstSQL_COLUMN_LABELAsLong=18PublicConstSQL_DROPAsLong=1PublicConstSQL_DRRORAsLong=-1Publi
7、cConstSQL_NO_DATA_FOUNDAsLong=100PublicConstSQL_SUCCESSAsLong=0PublicConstSQL_SUCCESS_WITH_INFOAsLong=1PublicConstSQL_ATTR_MAX_LENGTHAsLong=100'数据源信息常量PublicConstDATABASEAsString="newdb"PublicConstDSNAsString="newdb"PublicConstDB_USER_NAMEAsString="sa"PublicConstDB_PASSWO
8、RDAsString="sa"'版本号PublicConstVerNumAsString="版本1.0.01"'生成日期PublicConstGenDateAsString="日期2002-0