get a list of all database from a server in a html | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

get a list of all database from a server in a html

How can i get a list of all database from a server in a html file.and display them in a list/drop down that when a user select the database from dropdown box and click a submit button it should show the
details of that db in a html file
Why don’t you use for this. You can find code to just modify and use at MeanOldDBA
[email protected] When life gives you a lemon, fire the DBA.
Thank you for that information.Could you give me the link of that script on ll be grateful towards you. sandy
Here’s a little help that I put together quickly:<br /><br />The code segment below is a very basic version of what you may be looking for.<br />Paste this code into a text editor (such as NotePad) and save as file "default.asp"<br />Then set the file as the default page on a website or virtual directory.<br />This is old-style ASP so it should be compatible with any IIS Web server.<br /><br />The example below uses the "sp_helpdb" stored procedure to list the databases in an html drop-down and return some basic information on them when you select a database.<br />You will, of course, need to change the ServerName, UserName and Password in the example below to match your server login.<br /><br />If everything I’ve said above sounds confusing or if you need something more detailed, find someone who understands ASP and IIS to adapt and host this to suit your needs.<br />This topic is perhaps better suited to the Development forum and moderators may well move it there.<br />—————————-<br />&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;font size=3 face=arial&gt;<br />&lt;%<br />Dim Rs, Rs2, SQL, Db, i<br />Dim strServerName, strUserName, strPassword, strDBName <br />strServerName = "MyServer"<br />strUserName = "sa"<br />strPassword = "password"<br />strDBName = "master"<br />Set Db = Server.CreateObject("adodb.Connection")<br />strServerName = "driver={SQL Server};server=" & strServerName & ";uid=" & _<br />strUserName & "<img src=’/community/emoticons/emotion-4.gif’ alt=’;p’ />wd=" & strPassword & ";database=" & strDBName<br />Db.ConnectionString = strServerName<br />Db.ConnectionTimeout = 30<br />Db.CommandTimeout = 30<br />Db.Open<br /><br />Function DbQuery(strSQL)<br /> Set DbQuery = Db.Execute(strSQL)<br />End Function<br /><br />%&gt;<br />&lt;form name=form1 id=form1 method=post action=’default.asp’&gt;<br />Select Database: &lt;select name=’DBlist’&gt;<br />&lt;%<br />Set Rs=DbQuery("exec sp_helpdb")<br />Do Until Rs.EOF<br />Response.Write "&lt;option value=’" & Rs(0).Value & "’"<br />If Request("DBlist")=Rs(0).Value Then Response.Write " selected"<br />Response.Write "&gt;" & Rs(0).Value & "&lt;/option&gt;"<br />Rs.MoveNext<br />Loop<br />%&gt;<br />&lt;/select&gt;&lt;input type=submit name=’go’ value=’Submit’&gt;&lt;/form&gt;<br />&lt;%<br />If Request("go")&lt;&gt;"" Then<br />Set Rs=DbQuery("exec sp_helpdb ‘" & Request("DBlist") & "’")<br />For i= 0 to 6<br />Response.Write "&lt;b&gt;" & Rs(i).Name & "&lt;/b&gt;: &nbsp;" & Rs(i).Value & "&lt;br&gt;"<br />Next<br />End If<br />%&gt;<br />&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;<br />—————————————————-<br />