資源描述:
《在vb中用odbcapi訪問(wèn)數(shù)據(jù)庫(kù)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、一、聲明ODBCAPI函數(shù)???這些函數(shù)都在odbc32.dll中定義了,要在程序中調(diào)用這些函數(shù),必須首先對(duì)它們進(jìn)行聲明。建立一個(gè)模塊,在里面寫入下列內(nèi)容:'==聲明odbc32.dll中定義的ODBCAPI函數(shù)==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%)數(shù)據(jù)庫(kù)訪問(wèn)常量和數(shù)據(jù)源信息常量:'數(shù)據(jù)庫(kù)訪問(wèn)常量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'數(shù)據(jù)源信息常量PublicConstDATABASEAsString="newdb"PublicConstDSNAsString="newdb"PublicConstDB_USER_NAMEAsString="sa"PublicConstDB_PASSWO
8、RDAsString="sa"'版本號(hào)PublicConstVerNumAsString="版本1.0.01"'生成日期PublicConstGenDateAsString="日期2002-0