Click here to Skip to main content
15,885,216 members
Articles / Web Development / IIS

Universal Database Admin for ASP.NET and SQL Server (Reloaded)

Rate me:
Please Sign up or sign in to vote.
4.91/5 (87 votes)
15 Apr 20068 min read 437.1K   9.6K   200  
A dynamic web application needs an admin section for CRUD actions on the records/tables in the database. Wouldn't it be nice to have a database admin, which can be plugged to any web application? Just give your SQL connection string and it dynamically manages all table operations in just five pages.
<%@ Language=VBScript %>
<!--#include file=scripts/inc_common.asp-->
<%
	If Request.QueryString("action") = "logoff" Then 
		Session.Contents.Remove(DBA_cfgSessionPwdName)
		Session.Contents.Remove(DBA_cfgSessionUserName)
		Session.Contents.Remove(DBA_cfgSessionDBPathName)
		Session.Contents.Remove(DBA_cfgSessionDBPassword)
	End if
	if Request.Form("password") = DBA_cfgAdminPassword or not DBA_IsSecurityEnabled() then
		Session(DBA_cfgSessionPwdName) = DBA_cfgAdminPassword
		Session(DBA_cfgSessionUserName) = DBA_cfgAdminUsername
		If DBA_cfgSessionTimeout > 0 Then Session.Timeout = DBA_cfgSessionTimeout
		if DBA_IsSecurityEnabled() Then Response.Redirect "database.asp"
	end if
%>
<html>
<head>
<title>DBA:<%=langCaptionHome%></title>
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<link href="default.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript" src="scripts/common.js" defer></script>
<script type="text/javascript" language="javascript">
function onLoad(){
	var obj = document.getElementById('iPassword');
	if(obj){
		obj.focus();
	}
}
function bugReport(){
	var url = 'http://www.stpworks.com/redir.asp?linkid=5&p=1';
	url += '&iis=<%=Server.UrlEncode(GetIISVersion())%>&ado=<%=Server.UrlEncode(GetADOVersion())%>';
	url += '&browser=<%=Server.UrlEncode(Request.ServerVariables("HTTP_USER_AGENT"))%>';
	url += '&se=<%=Server.UrlEncode(ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion & "." & ScriptEngineBuildVersion)%>';
	DBA_popupWindow(url, 'bug', 640, 480);
}
</script>
</head>

<body onload="javascript:onLoad();">

<%call DBA_WriteNavigation%>
<h2 align="center"><%=langWelcomeHeader%></h2>
<p align="center"><%=langVersion & "&nbsp;" & DBA_VERSION%></p>

<%call DBA_BeginNewTable(langWelcome, "", "75%", "")%>

<p align="center"><%=langWelcomeNote%></p>
<br>

<%
	if Session(DBA_cfgSessionPwdName) <> DBA_cfgAdminPassword and DBA_IsSecurityEnabled() then
		call WriteLoginForm
	else
		call WriteMainPage
	end if
%>

<%call DBA_EndNewTable%>

<!--#include file=scripts/inc_footer.inc-->
</body>
</html>

<%Sub WriteLoginForm%>
<p align="center"><%=langWelcomeNote2%></p>
<form action="default.asp" method="post">
	<table cellspacing="1" cellpadding="1" border="0" align="center">
		<tr>
			<td><%=langEnterPassword%></td>
			<td><input type="password" name="password" id="iPassword"></td>
		</tr>
		<tr>
			<td colspan="2" align="center"><input type="submit" value="<%=langSubmit%>" name="submit" class="button"></td>
		</tr>
	</table>
</form>
<%End Sub%>

<%Sub WriteMainPage%>
<table align="center" border="0" cellpadding="25" cellspacing="1">
	<tr>
		<td align="center" valign="top">
			<a href="settings.asp"><img src="images/icon_settings.gif" border="0" width="48" height="48" alt="<%=langSettings%>"></a>
			<h5><%=langSettings%></h5>
		</td>
		<td align="center" valign="top">
			<a href="javascript:bugReport();">
				<img src="images/icon_submit_bug.gif" width="48" height="48" border="0" alt="<%=langSubmitBug%>">
			</a>
			<h5><%=langSubmitBug%></h5>
		</td>
		<td align="center" valign="top">
			<a href="default.asp?action=logoff"><img src="images/icon_logoff.gif" border="0" width="48" height="48" alt="<%=langLogOff%>"></a>
			<h5><%=langLogOff%></h5>
		</td>
	</tr>
</table>
<%End Sub%>

<%
	'Several functions for bug reporting
	Function GetADOVersion()
		'On Error Resume Next
		dim con
		Set con = Server.CreateObject("ADODB.Connection")
		GetADOVersion = "" & con.Version
		set con = Nothing
	End Function
	
	Function GetIISVersion()
		GetIISVersion = Request.ServerVariables("SERVER_SOFTWARE")
	End Function
%>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Founder Teamcal AI
United States United States

Comments and Discussions