Click here to Skip to main content
12,448,059 members (85,172 online)
Click here to Skip to main content
Articles » Database » Database » General » Downloads

Stats

204.8K views
2.4K downloads
59 bookmarked
Posted

Online DB Administration

, 17 Mar 2003
Online administration of your database. Create or modify tables, keys, and indexes. Edit or insert data.
<%@language=javascript%>
<!--#include file=common.asp-->
<!--#include file=b.grid.asp-->
<%
	function Content(Conn) {
		var oCat = Server.CreateObject("ADOX.Catalog");
		oCat.ActiveConnection = Conn;

		if(Request.QueryString("key").Count==1 && Request.QueryString("cmd").Count==1 && Request.QueryString("cmd").Item=="dropkey") {
			oCat.Tables(Request.QueryString("table").Item).Keys.Delete(Request.QueryString("key").Item);
			oCat.Tables(Request.QueryString("table").Item).Keys.Refresh();
		}
		
		Out('<table class="list" cellspacing="0" cellpadding="0">');
		Out("<tr>");
		Out("<th>Name</th>");
		Out("<th>Related Table</th>");
		Out("<th>Type</th>");
		Out("<th>Delete Rule</th>");
		Out("<th>Update Rule</th>");
		Out("<th>Columns</th>");
		Out('<th>Commands</th>');
		Out("</tr>");

		for(var e=new Enumerator(oCat.Tables(Request.QueryString("table").Item).Keys);!e.atEnd();e.moveNext()) {
			var oCol = e.item();
		
			Out("<tr class=\"gridrow\">");
			if(oCol.Type==adKeyPrimary)
				Out('<td><img src="images/pk.gif" align="absmiddle"/>&nbsp;' + oCol.Name + '</td>');
			else if(oCol.Type==adKeyForeign)
				Out('<td><img src="images/fk.gif" align="absmiddle"/>&nbsp;' + oCol.Name + '</td>');
			else
				Out('<td><img src="images/column.gif" align="absmiddle"/>&nbsp;' + oCol.Name + '</td>');
			Out("<td>" + (oCol.RelatedTable!='' ? oCol.RelatedTable : '&nbsp;') + "</td>");
			Out("<td>" + GetKeyTypeEnum(oCol.Type) + "</td>");
			Out("<td>" + GetRuleEnum(oCol.DeleteRule) + "</td>");
			Out("<td>" + GetRuleEnum(oCol.UpdateRule) + "</td>");

			Out("<td>");
			var s = "";
			for(var c=new Enumerator(oCol.Columns);!c.atEnd();c.moveNext()) {
				if(""+c.item().Name!="undefined") {
					if(s!="") s += ", ";
					s += c.item().Name;
				}
			}
			if(s=="") s = "&nbsp;";
			else s = s.slice(0,s.length-2);
			Out(s);
			Out("</td>");

			Out("<td>");
			Out('<a href="javascript:DropKey(\''+Request.QueryString("table").Item+'\',\''+oCol.Name+'\')">Drop</a>');
			Out("</td>");

			Out("</tr>");
		}

		Out('<tr><td colspan="7">');
		Out('<a href="createkey.asp?table='+Request.QueryString("table").Item+'">Create a new key</a>');
		Out("</td></tr>");
		Out("</table>");

		Out('<br>');
		Out('<table class="list" cellspacing="0" cellpadding="0">\n');
		Out('<tr>\n');
  		Out('<td>&nbsp;<a href=".">Back</a>&nbsp;</td>\n');
  		Out('</table>\n');
	}

	PageSetup();
	NewPageHeader();
	Content(Object.Conn);
	NewPageFooter();
	PageCleanup();
%>

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

Share

About the Author

Bjornar Henden
Web Developer
Norway Norway
No Biography provided

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160811.3 | Last Updated 18 Mar 2003
Article Copyright 2002 by Bjornar Henden
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid