问题描述
ImportsSystem.Data.OleDbPublicClassTestModulePrivateSharedunlockMLAsTestModule=NothingPrivateSharedReadOnlyobjAsObject=NewObjectPublicSharedFunctionGetInstance()AsTestModuleSyncLockobjIfunlockMLIsNothingThenunlockML=NewTestModuleEndIfReturnunlockMLEndSyncLockEndFunctionPrivateSubNew()EndSubPublicFunctionQueryLAList(ByValstrTableNameAsString,ByValdbAsString,ByValdbtypeAsString,ByValstrSqlAsString)AsDataSetDimdsAsDataSetDimconnAsOleDbConnectionDimcmdAsOleDb.OleDbCommandDimdaAsOleDb.OleDbDataAdapterTryconn=SqlFactory.GetInstance.CreateConnection(WebDll.Parameters.WebApp,db,dbtype)Ifconn.State=ConnectionState.ClosedThenconn.Open()EndIfds=NewDataSetcmd=NewOleDbCommandcmd.CommandType=CommandType.Textcmd.CommandText=strSqlcmd.Connection=connda=NewOleDbDataAdapter(cmd)da.Fill(ds,strTableName)ReturndsCatchexAsExceptionThrowexFinallycmd.Dispose()conn.Close()EndTryEndFunctionEndClass-----------------以上是我写的一个单态访问数据的类--------接着我在一个页面中放了一个button,在button中调用这个类中的QueryLAList方法,DimdsAsDataSet=TestModule.GetInstance().QueryLAList("LA",DB.Text,DBTYPE.Text,sql.Text)dg.DataSource=ds.Tables("LA").DefaultViewdg.DataBind()这里想请教各位大侠,如果有多个用户同时访问会有问题么?这样写单态的类在ASP.NET中可行么?或有什么潜在的问题么?
解决方案
解决方案二:
ding