数据库
首页 > 数据库> > 搬家第一天4.WinccV7.3删除数据库mydatabase

搬家第一天4.WinccV7.3删除数据库mydatabase

作者:互联网

Sub OnClick(ByVal Item) 
Dim ors,conn,con,ssql,ocom
Dim PCName
PCName=HMIRuntime.Tags("@LocalMachineName").Read
con="Provider = SQLOLEDB.1;password = sa;user id = sa;Initial Catalog =master;Data Source = " & PCName & "\WINCC"
''con="Provider = SQLOLEDB.1;password = sa;user id = sa;Data Source = " & PCName & "\WINCC"

Set conn=CreateObject("ADODB.Connection")
conn.ConnectionString=con
conn.Cursorlocation=3
conn.open
ssql="select * from master.dbo.sysdatabases where [name] ='MyDataBase'"
''ssql="select name from dbo.sysdatabases where name ='MyDataBase'"
Set ors=CreateObject("ADODB.RecordSet")
Set ocom=CreateObject("ADODB.Command")
Set ocom.activeconnection=conn
ocom.CommandType=1
ocom.CommandText=ssql
Set ors=ocom.Execute
If ors.recordcount>0 Then
   ssql="drop Database MyDatabase"
   ocom.CommandText=ssql
   Set ors=ocom.Execute
   Msgbox "MyDatabase删除完毕"
Else
  Msgbox "MyDataBase不存在,无需删除"


End If
Set ors=Nothing
conn.close
Set conn=Nothing
End Sub

标签:Set,WinccV7.3,ocom,mydatabase,数据库,ors,sa,conn,ssql
来源: https://www.cnblogs.com/fishingsriver/p/14342882.html