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 box.so that when a user select the database from dropdown box and click a submit button it should show thedetails of that db in a html file
Why don’t you use asp.net for this. You can find code to just modify and use athttp://www.asp.net MeanOldDBA
[email protected] When life gives you a lemon, fire the DBA.
Hi!
Thank you for that information.Could you give me the link of that script on www.asp.net.I 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 /><html><head></head><body><font size=3 face=arial><br /><%<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 />%><br /><form name=form1 id=form1 method=post action=’default.asp’><br />Select Database: <select name=’DBlist’><br /><%<br />Set Rs=DbQuery("exec sp_helpdb")<br />Do Until Rs.EOF<br />Response.Write "<option value=’" & Rs(0).Value & "’"<br />If Request("DBlist")=Rs(0).Value Then Response.Write " selected"<br />Response.Write ">" & Rs(0).Value & "</option>"<br />Rs.MoveNext<br />Loop<br />%><br /></select><input type=submit name=’go’ value=’Submit’></form><br /><%<br />If Request("go")<>"" Then<br />Set Rs=DbQuery("exec sp_helpdb ‘" & Request("DBlist") & "’")<br />For i= 0 to 6<br />Response.Write "<b>" & Rs(i).Name & "</b>: " & Rs(i).Value & "<br>"<br />Next<br />End If<br />%><br /></font></body></html><br />—————————————————-<br />
]]>