Tuesday, March 27, 2012

getting the database collection doesnt always wrok

why doesn't this code always work?

<code>

Dim conn as serverconnection=New serverconnection(".\SQLEXPRESS")

Dim srv as new server(conn)

Dim db as database

for each db in srv.databases

cmbDBfilenames.items.add(db.Name.tostring)

Next

</code)

If the databases are located in the applicatio path , it doesn't pick them up


Hi,

The method you are using only checks for the server attached databases not the user instances. So if the database is in the application path, but SQL Server does not hold an actual reference to them (being attached to the databases) you won′t find them (SMO makes a call to the server to evaluate the available databases)


HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

sql

No comments:

Post a Comment