Click here to Skip to main content
15,881,826 members
Articles / Programming Languages / ASP

Online DB Administration

Rate me:
Please Sign up or sign in to vote.
3.88/5 (16 votes)
17 Mar 2003 236K   2.5K   58  
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("cmd").Count==1 && Request.QueryString("column").Count==1 && Request.QueryString("cmd").Item=="drop") {
			oCat.Tables(Request.QueryString("table").Item).Columns.Delete(Request.QueryString("column").Item);
			oCat.Tables(Request.QueryString("table").Item).Columns.Refresh();
		}

		var oTable = oCat.Tables(Request.QueryString("table").Item);
		Out('<table class="list" cellspacing="0" cellpadding="0">');
		Out("<tr>");
		Out("<th>Column Name</th>");
		Out("<th>Data Type</th>");
		Out("<th>Defined Size</th>");
		Out("<th>Numeric Precision</th>");
		Out("<th>Numeric Scale</th>");
		Out("<th>Allows Nulls</th>");
		Out("<th>Commands</th>");
		Out("</tr>");

		for(var e=new Enumerator(oTable.Columns);!e.atEnd();e.moveNext()) {
			var oCol = e.item();
			var sImage = 'images/column.gif';
		
			Out("<tr>");
			Out("<td><img src=\""+sImage+"\" align=\"absmiddle\"/>&nbsp;" + oCol.Name + "</td>");
			Out("<td>" + BGrid_GetDataTypeEnum(oCol.Type) + "</td>");

			Out("<td align=\"right\">" + oCol.DefinedSize + "</td>");

			if(""+oCol.NumericPrecision=="undefined") Out("<td>&nbsp;</td>");
			else Out("<td align=\"right\">" + oCol.NumericPrecision + "</td>");
			
			Out("<td align=\"right\">" + oCol.NumericScale + "</td>");
			
			Out("<td>" + (oCol.Attributes & 2 ? "yes" : "no") + "</td>");

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

			Out("</tr>");
		}
		Out('<tr><td colspan="7">');
		Out('<a href="createcolumn.asp?table='+oTable.Name+'">Add a new column</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


Written By
Web Developer
Norway Norway
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions