资源描述:
《vb中调用sql数据库数据的登陆界面(vb call sql database data in the login screen)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、vb中调用sql数据库数据的登陆界面(VBcallSQLdatabasedataintheloginscreen)VBcallSQLdatabasedataintheloginscreenRewardpoints:100-solvethetime:2009-11-1720:27Mygeneralmodulecode:Public,Conn,As,New,ADODB.ConnectionPublic,RS,As,New,ADODB.RecordsetPublicaddflagAsBooleanPublic,Sub,clocn()OnErrorResumeNextIfcon
2、n.StateadStateClosedThenconn.Close"Setconn=NothingEndSubPublicfMainFormAsfrmMainPublicUserNameAsStringPublic,Function,ConnectString(),As,String'returnsaDBConnectStringConnectString="Provider=Microsoft.jet.oledb.4.0;datasource="&App.Path&jlb.mdb,End,FunctionPublic,Function,ExecuteSQL(ByV
3、al,SQL,As,String,As,String)As,ADODB.Recordset,'executes,SQL,MsgString,and,returns,RecordsetDimCNNAsADODB.ConnectionDimRSTAsADODB.RecordsetDimsTokens()AsStringOnErrorGoToExecuteSQL_ErrorSTokens=Split(SQL)SetCNN=NewADODB.ConnectionCnn.OpenConnectString'connecttothedatabaseIfInStr("INSERT,D
4、ELETE,UPDATE",UCase$(sTokens(0)),"Then",ifinsertdeleteupdateappearsintheinputSQLstatement,executetheSQLcodeCnn.ExecuteSQLMsgString=sTokens(0)&"querysuccessful""ElseSetRST=NewADODB.RecordsetRst.OpenTrim$(SQL),CNN,adOpenKeyset,adLockOptimistic'executequerycode(andabovesimilarfunctions,thed
5、ifferenceisthattheaboveistheimplementationofthedatabaseisupdated,includingdeleteincreaseupdate,andhereisthequery)The'rst.MoveLastrecordsetmovestothenextrecord,'GetRecordCount,togetthetotalnumberofdatabaseentriesSetExecuteSQL=RSTexecutesdatabasequeriesMsgString=queryto&rst.RecordCount&Bar
6、record'displaysthenumberofrecordstoqueryEndIfExecuteSQL_Exit:SetRST=NothingSetCNN=Nothing'>toclosetherecordsetandthedatabaseconnectionobjectExitFunctionExecuteSQL_Error:MsgString=queryerror:&Err.DescriptionResumeExecuteSQL_ExitEndFunctionPublic,Function,Testtxt(txt,As,String)AsBooleanIfT
7、rim(txt)="Then"Testtxt=FalseElseTesttxt=TrueEndIfEndFunction"Todeterminewhetherthetxtisemptyandtosettesttxttotrueorfalse,PublicSubclors()OnErrorResumeNextIfrs.StateadStateClosedThenrs.Clone"Setrs=NothingEndSubLandinginterfacebuttoncodetodetermine:Private,Sub,Command1_Clic