資源描述:
《vb sql語(yǔ)句事例代碼(vb sql statement instance code)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫(kù)。
1、vb+sql語(yǔ)句事例代碼(Vb+sqlstatementinstancecode)ThespecificcodeofVBdesign----------------------------------------------One.Therequiredclass[Students]//students----Memberfunctions(implementationofspecificfunctionsandellipsisofparameters)Init//notannotatedandsimilartotheabove,donotgointod
2、etailsDeleteGetInfoGetNameGetNewldInsertLoad_By_Class//readthespecifiedclassallthestudentstothearrayofArr_StuId(Arr_StuName)and(in)UpdateClass_IdUpdate_Transfer//modifythespecifiedclassinformationofthestudents,thestudentsintheprocessofusingclassswitchSpecificimplementationofLoad_
3、By_Class:{PulicSubLoad_By_Class(ByValTempClassIdAsInteger)DimIAsInteger//initializeanarrayclassTheEraseArr_StuId//ErasestatementinitializestheelementsofthefixedsizearrayandreleasesthestoragespaceofthedynamicarrayReDimArr_StuId(0)//ReDimallocatesstoragespaceforarrayvariablesEraseA
4、rr_StuNameReDimArr_StuName(0)DB_Connect//databaseconnectionSqlStmt="SELECTStudent_Id,Student_NameFROMStudentsWHEREClass_Id-"="+Trim(Str(TmpClassId))+"ORDERBYStudent_Id"http://toexecuteanSQLstatementTheroleof//VBinTrimistoremovespacesinstrings,forexample,hereRemovethespacefromthestring
5、TmpClassIdandassignittoClass_Id.OdbcExt(SqlStmt)//SQLstatementisexecutedI=0ThefunctionofDoUnitilSQLFetch(Hstmt)=SQL_NO_DATA_FOUND//SQLFetchfunctionistoThecurrentrecordpointeroftheresultsetmovestothenextrecordColVa=String(40,0)Rc=SQLGetData(Hstmt,1,1,ColVal,Len(ColVal),pcblen)ReDi
6、mPreserveArr_StuId(I+1)Arr_StuId(I)=Val(ColVal)ColVal=String(40,0)Rc=SQLGetData(Hstmt,2,1,ColVal,Len(ColVal),pcblen)ReDimPreserveArr_StuName(I+1)Arr_StuName(I)=TrimStr(ColVal)I=I+1LoopRc=SQLFreeStmt(Hstmt,SQL_DROP)DB_Disconnect//disconnectfromthedatabaseconnectionEndSub}[Experien
7、ce](specificfunctionsandparametersomitted)/educationalexperience------Memberfunctions(implementationofspecificfunctionsandellipsisofparameters)InitDeleteByld//deletestudentrecordsAllrecordsofDeleteByStudentld//deletethespecifiedstudentsGetInfoInsertUpdateSpecificimplementationofD
8、eleteByld:{PublicSubDeleteByld(ByValTmpI