ADO2使用说明文档

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

AsetofADOClasses-version2.10ByCarlosAntolliniOverviewTheCADODatabaseClassCADODatabaseOpenExecuteGetRecordsAffectedGetActiveConnectionGetRecordCountBeginTransactionCommitTransactionRollbackTransactionIsOpenCloseSetConnectionStringGetConnectionStringSetConnectionModeGetLastErrorGetLastErrorStringTheCADORecordsetClassCADORecordsetOpenExecuteGetQuerySetQueryRecordBindingGetRecordCountIsOpenCloseGetFieldCountGetFieldValueIsFieldNullIsFieldEmptyIsEofIsBofMoveAbsolutePageGetPageCountPageSizeAbsolutePositionGetFieldInfoGetChunkAppendChunkGetStringGetLastErrorGetLastErrorStringAddNewEditDeleteUpdateCancelUpdateSetFieldValueFindFindFirstFindNextGetBookmarkSetBookmarkSetFilterSetSortGetRecordsetGetActiveConnectionCloneSaveAsXMLOpenXMLTheCADOParameterClassCADOParameterSetPrecisionSetScaleSetValueGetValueSetNameGetNameGetTypeGetParemeterTheCADOCommandClassCADOCommandAddParameterSetTextGetTextSetTypeGetTypeGetCommandExecuteGetRecordsAffectedTheCJectEngineClassCompactDatabaseCommonQuestionsOverviewIcreatedtheseclassestomakeiteasytoworkwithado.ForthisIcreatedtheCADODatabseclassandtheCADORecordsetclassTheCADODatabaseClassTheCADODatabaseclasshasasetoffunctionsthatcorrespondstothe_ConnectionPtrCADODatabase::CADODatabaseCreatesaCADODatabaseobject.CADODatabase();CADODatabase::OpenTheOpenfunctionOpensaconnectiontoaDatabase.BOOLOpen(LPCTSTRlpstrConnection=_T());ParametersLPCTSTRlpstrConnectionTheconnectionstring.SeesampleNote:theclasshasthefunctionSetConnectionString.Youcaninserttheconnecctionstringthroughthisfunction.Inthiscaseyoucandothefollowing.//SamplewithConnectionstringforSQLServerCADODatabase*pAdoDb=newCADODatabase();CStringstrConnection=_T();strConnection=_T(Provider=MSDASQL;PersistSecurityInfo=False;Trusted_Connection=Yes;DataSource=AccessSqlServer;catalog=sampledb);pAdoDb-SetConnectionString(strConnection);if(pAdoDb-Open())DoSomething();...//SamplewithConnectionStringforAccessdatabaseCADODatabase*pAdoDb=newCADODatabase();CStringstrConnection=_T();strConnection=_T(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\\VCProjects\\ADO\\Test\\dbTest.mdb);pAdoDb-SetConnectionString(strConnection);if(pAdoDb-Open()){DoSomething();...pAdoDb-Close();}deletepAdoDb;CADODatabase::ExecuteTheExecutefunctionexecutesasqlstatementintheopendatabase.BOOLExecute(LPCTSTRlpstrExec)ParametersLPCTSTRlpstrExecAstringpointercontaininigthesqlstatementtoexecute.CADODatabase*pAdoDb=newCADODatabase();CStringstrConnection=_T();strConnection=_T(Provider=MSDASQL;PersistSecurityInfo=False;Trusted_Connection=YesDataSource=AccessSqlServer;catalog=sampledb);if(pAdoDb-Open(strConnection))pAdoDb-Execute(DeleteFromtblClientsWhereCheker=3);ReturnValueThefunctionreturnsTRUEifwassuccesfully.CADODatabase::GetRecordsAffectedTheGetRecordsAffctedfunctionreturnsthenumberofrecordsaffectedtothelastsqlstatementexecuted.intGetRecordsAffected();CADODatabase::GetActiveConnectionTheGetActiveConnectionreturnstheactiveconnection._ConnectionPtrGetActiveConnection();CADODatabase::GetRecordCountGetRecordCountreturnsthenumberofrecordsaffectedinaquery.DWORDGetRecordCount(_RecordsetPtrm_pRs);Parameters_RecorsetPtrm_PrsTherecordset.CADODatabase::BeginTransactionCallthisfunctiontoinitiateatransaction.AfteryoucallBeginTransaction,updatesyoumaketoyourdatatakeeffectwhenyoucommitthetransaction.longBeginTransaction();CADODatabase::CommitTransactionCallCommitTransactionfunctiontocommitatransactionforexamplesaveagroupofeditsandupdatestooneormoredatabases.longCommitTransaction();CADODatabase::RollbackTransactionCallRollbackTransactionfunctiontoendthecurrenttransactionandrestorealldatabasestotheirconditionbeforethetransactionwasbegun.longRollbackTransaction();CADODatabase::IsOpenTheIsOpenfuntionreturnsthestatusoftheconnectionwiththedatabase.BOOLIsOpen();ReturnValueThefunctionreturnsTRUEiftheconnectiontodatabaseisopen.CADODatabase::CloseTheClosefunctionclosetheconnectiontothedatabase.voidClose();CADODatabase::SetConnectionStringWiththeSetConnectionStringYoucaninserttheconnectionstring.voidSetConnectionString(LPCTSTRlpstrConnection);ParametersLPCTSTRlpstrConnectionAconnectionstringusedforopeningthedatabase.seeCADODatabase::Open()CADODatabase::GetConnectionStringTheGetConnectionStringfunctionreturnstheconnectionstringusedformakeaconnectionwithadatabase.CStringGetConnectionString();CADODatabase::SetConnectionModeTheSetConnectionModefunctionsetsthemodeofconnection.voidSetConnectionMode(cadoConnectModeEnumnMode);ParameterscadoConnectModeEnumnModeavariablethatdefinestheconnectionmodetobeused.Itcanbeoneofthefollowing:CADODatabase::connectModeUnknownCADODatabase::connectModeReadCADODatabase::connectModeWriteCADODatabase::connectModeReadWriteCADODatabase::connectModeShareDenyReadCADODatabase::connectModeShareDenyWriteCADODatabase::connectModeShareExclusiveCADODatabase::connectModeShareDenyNoneCADODatabase::GetLastErrorTheGetLastErrorfunctionreturnsthelasterrorcode.DWORDGetLastError();CADODatabase::GetLastErrorString

1 / 42
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功