ProgrammingMSAccess.com

Learn about Developers Group
Join Developers Group
Order SPAM Blocker
Free Stuff
Guest Book
.NET Resources
SQL Server Resources
Favorites
Technical Support
Books & DVDs by Webmaster
Articles, tutorials, & more
FAQs
Product Reviews
Samples
Prior Newsletters
Contact Us
Home
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

a pair of procedures for enumerating the databases on a sql server.  update the string assignment for srvname in call_enumerate_databases so that it points at your server's name.  these sub procedure require a reference to the sql-dmo object library.  notice that they use the connect_to_server function procedure listed elsewhere on this site.

Sub call_enumerate_databases()
Dim srvname As String

'Set string constant for
'connect_to_server procedure
srvname = "cabarmada"

'Check for valid server connection before
'attempting to enumerate databases
If connect_to_server(srvname) = True Then
enumerate_databases
End If

End Sub


Sub enumerate_databases()
Dim dbs1 As SQLDMO.Database

'Print message reporting number of databases
'on target server
Debug.Print "There are " & srv1.Databases.Count & " databases " & _
"on " & srv1.Name; "." & vbCrLf & "Their names and sizes " & _
"in MB are:" & vbCrLf

'Iterate through databases on target server
For Each dbs1 In srv1.Databases
Debug.Print dbs1.Name & String(25 - Len(dbs1.Name), " ") & _
dbs1.Size
Next

'Clean up
Set dbs1 = Nothing
srv1.Close
Set srv1 = Nothing

End Sub

Want to understand  Microsoft Access 2000 so that you can program it to do more tasks like this?  Get Programming Microsoft Access 2000 by Rick Dobson from Microsoft Press.  Learn more about the book by clicking here.

Copyright 2000 CAB, Inc. All rights reserved. Republication or redistribution of CAB, Inc. content, including by framing or similar means, is expressly prohibited without the prior written consent of CAB, Inc. CAB, Inc. shall not be liable for any errors in the content, or for any actions taken in reliance thereon.