|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQLAB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。server|数据|数据库
程序编写:陈林茂
‘编写日期:2003-01-01
当您的MIS体系开辟好今后,您怎样尽快的分发您的数据库呢?
上面我将供应VB代码的详细完成:
OptionExplicit
definethesqlconnect
DimoSQLServerAsSQLDMO.SQLServer
DimoCurrentDBAsSQLDMO.Database
DimoCurrentTableAsSQLDMO.Table
DimoTestIdxAsSQLDMO.Index
sqlDmoisConnectedYesorNo
PublicsNameAsString
PrivateIsConnectedAsBoolean
connecttolocaldatabaseserver
PublicFunctionConnectDmo()AsBoolean
OnErrorGoToHandleError
Ifwereconnected,thendisconnectandclearlists.
IfIsConnected=TrueThen
oSQLServer.DisConnect
IsConnected=False
EndIf
Beginconnecttosqlserverormsde
Attemptaconnection,thenfillthepropertiesstuff.
oSQLServer.ApplicationName="SQL-DMOIndexTest"
oSQLServer.LoginSecure=True
connect
oSQLServer.Connect"(local)","sa",""
IsConnected=True
ConnectDmo=True
HandleError:
connectfailth
IfIsConnected=FalseThen
IsConnected=False
ConnectDmo=False
EndIf
EndFunction
addaexistsdatabasetoserver
PublicFunctionAddDataBase(ByValdbNameAsString,ByValDBPathAsString,ByValrstrAsString)AsBoolean
Dimrstring
rstring=oSQLServer.AttachDBWithSingleFile(dbName,DBPath)
rstring=oSQLServer.AttachDB(dbName,DBPath)
AddDataBase=True
rstr=rstring
EndFunction
deletetheexistsdatabase
PublicFunctionDelDataBase(ByValdbNameAsString)AsBoolean
Dimrstring
rstring=oSQLServer.DetachDB(dbName)
DelDataBase=True
EndFunction
PrivateSubUserControl_Initialize()
OnErrorGoTomerror
SetoSQLServer=NewSQLDMO.SQLServer
oSQLServer.LoginTimeout=15
oSQLServer.ODBCPrefix=False
Name="msdeconn1"
merror:
EndSub
PublicFunctionisDBexists(ByValdbNameAsString)AsBoolean
DimoDBAsSQLDMO.Database
DimrcAsBoolean
reconnecttodatabase
oSQLServer.DisConnect
oSQLServer.ReConnect
rc=False
ForEachoDBInoSQLServer.Databases
IfoDB.SystemObject=FalseThen
IfTrim(UCase(oDB.Name))=Trim(UCase(dbName))Then
rc=True
EndIf
EndIf
NextoDB
setthereturnvalue
isDBexists=rc
EndFunction
PrivateSubUserControl_Terminate()
endconnectthedatabase
oSQLServer.Close
EndSub
PublicFunctionstartServer()
oSQLServer.StartTrue
EndFunction
PublicSubstopserver()
oSQLServer.Stop
EndSub
PublicPropertyGetName()AsVariant
Name=sName
EndProperty
PublicPropertyLetName(ByValvNewValueAsVariant)
sName=vNewValue
EndProperty
在执行崩溃恢复时,理解在一个数据库中的每一个表tbl_name对应的在数据库目录中的3个文件是很重要的: |
|