select *
from sysobjects
where xtype='u' and name='databasename'
from sysobjects
where xtype='u' and name='databasename'
解决方案 »
- 这种打包软件有木有????
- 在字符串A或文本文件中查找字符串B出现的次数的解决方法,分享
- 用过Axure的帮我看下,如何去掉站点地图的问题,谢谢
- [求助]谁能拖动无标题样的椭圆形的EXCEL工作表?(附图)
- 如何处理这样的文本内容?
- 如何实现FOR批量判断控件(已定义控件为0,1,2,3..)?
- 在程序中如何判断SQLserver中是否有该表
- 如何使ListBox中 最新加入的Item反亮显示
- 用MATLAB VB 或 VFP怎么写这个啊?
- MP3歌曲能用VB加密吗?
- 关于datagrid的一个简单问题******在线等候*******
- 一个不很简单但大家都一定关心的问题!《如果何在网格实现多行游离编辑,最后更新数据库》
use master
select name from sysdatabases where name='attend'其中attend为数据库名,如果有则返回
'Add the Reference of "microsoft SQLDMO Object Library"
'Add a ComboBox On the Form,named cboServer
'Add a Checkbox On the Form,named chkNTSecurity
'Add two textbox On the Form,named txtUID,txtPWD
'Add a CommandBox On the Form,named cmdConnect
'Add a textbox On the Form,named txtDatabase(the Database you want to check whether exist)
'Add a CommandBox On the Form,named cmdCheck
'This Program is to Show How to Use SQLDMO to Check a Database whether ExistDim oSQLServer As New SQLDMO.SQLServerPrivate Sub cboServer_Change()
cmdConnect.Enabled = True
End SubPrivate Sub chkNTSecurity_Click() If chkNTSecurity.Value = vbChecked Then
txtUID.Enabled = False
txtPWD.Enabled = False
End If
End SubPrivate Sub cmdCheck_Click()
' lstDatabases.Text = txtDataBase.Text
' If lstDatabases.ListIndex <> -1 Then
' MsgBox "The DataBase is Exist!"
' Else
' MsgBox "The DataBase isn't Exist!"
' End If
Dim oDatabase As SQLDMO.Database
On Error GoTo CheckError
' Check the databases whether exist
For Each oDatabase In oSQLServer.Databases
If oDatabase.Status <> SQLDMODBStat_Inaccessible Then
'
If UCase(txtDatabase.Text) = UCase(oDatabase.Name) Then
MsgBox "The Database You want to check is exist!"
Exit Sub
End If
End If
Next oDatabase
MsgBox "The Database You want to check isn't exist!"
Exit Sub
CheckError:
SQLDMOError
End SubPrivate Sub cmdConnect_Click() On Error GoTo ConnectError
MousePointer = vbHourglass
' Setup a secure login for NT security
If chkNTSecurity.Value = vbChecked Then
oSQLServer.LoginSecure = True
End If
' Connect to the selected SQL Server system
oSQLServer.Connect cboServer.Text, txtUID.Text, txtPWD.Text
'Disabled the Connect Button
cmdConnect.Enabled = False
MousePointer = vbDefault
Exit Sub
ConnectError:
SQLDMOError
MousePointer = vbDefault
End SubPrivate Sub Form_Load() Dim oApplication As New SQLDMO.Application
Dim oServerGroup As SQLDMO.ServerGroup
Dim oRegisteredServer As SQLDMO.RegisteredServer
cboServer.Clear
' Process all the server groups
For Each oServerGroup In oApplication.ServerGroups
' Process each registered server
For Each oRegisteredServer In oServerGroup.RegisteredServers
' Add each name to the combobox
cboServer.AddItem oRegisteredServer.Name
Next
Next
Set oRegisteredServer = Nothing
Set oServerGroup = Nothing
Set oApplication = Nothing
End SubPublic Function SQLDMOError()
Dim sErrorMsg As String
sErrorMsg = Err.Source & " Error: " & _
Err.Number - vbObjectError & ": " & Err.Description SQLDMOError = MsgBox(sErrorMsg, vbOKOnly, "SQL-DMO Error")End Function
Private Sub cboServer_Click()
cmdConnect.Enabled = True
End Sub