With Access, you would simply use FileSystemObject's FileExists method to verify the location of the MDB file. e.g.:
<% databaseName = "databaseName" set fso = CreateObject("Scripting.FileSystemObject") if fso.fileExists(server.MapPath("/" & databaseName & ".mdb")) then response.write "Database exists." else response.write "Database does not exist." end if set fso = nothing %> |
With SQL Server, you can run the following query:
<% databaseName = "databaseName" cst = "Provider=SQLOLEDB;" & _ "Data Source=<x.x.x.x>;" & _ "Network=DBMSSOCN;" & _ "User Id=<uid>;" & _ "Password=<pwd>" set conn = CreateObject("ADODB.Connection") conn.open connStr SQL = "SELECT 1 FROM INFORMATION_SCHEMA.SCHEMATA" & _ " WHERE CATALOG_NAME='" & databaseName & "'" set rs = conn.execute(sql) if not rs.eof then response.write("Database exists.") else response.write("Database does not exist.") end if rs.close: set rs = nothing conn.close: set conn = nothing %> |