连接一下MASTER,连接不上。
连接一下你的数据库,连接不上。
if exists(select * from sysobjects where name='yourtablename')
   print 'exists'
else
   print 'not exists'

解决方案 »

  1.   

    1.数据库是否存在?
    use master
    if not exists(select * from sysdatabases where name='dbname')
    print 'Not Exists!'
    else
    print 'Exists!'
    2.数据表是否存在?
    use dbname
    if not exists(select * from sysobjects where id=object_id('tab'))
    print 'Not Exists!'
    else
    print 'Exists!'
      

  2.   

    引用SQLDMO,加一个名为txtServer的ComboBox控件
          
          Set  oSQLServerDMOApp  =  New  SQLDMO.Application
          Dim  namX  As  NameList
          Set  namX  =  oSQLServerDMOApp.ListAvailableSQLServers
          For  i  =  1  To  namX.Count
              txtServer.AddItem  namX.Item(i)
          Next
          'Show  top  server
          txtServer.ListIndex  =  0
      
    得到局域网中的SQL服务器的名