Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » General » Downloads
 
Add your own
alternative version

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(oConn) {
		var sViewName = '';
		if(Request.Form("vname").Count==1) sViewName = Request.Form("vname").Item;
	
		if(Request.Form("create").Count==1) {
			var sql = '';
			try {
				if(IsJet(oConn))
					sql = "create view [" + sViewName + "] as " + Request.Form("sql").Item;
				else
					sql = "create view \"" + sViewName + "\" as " + Request.Form("sql").Item;

				oConn.Execute(sql);
				EndPage('.');
				return;
			}
			catch(e) {
				Out('\n<s'+'cript type="text/javascript">\nSetErrorMessage("' + e.description + '");\n</scr'+'ipt>\n');
			}
		}

		Out('<table class="list" style="width:100%" cellspacing="0" cellpadding="0">');
		Out('<tr><th>Enter name:</th></tr>');
		Out('<tr><td><input type="text" name="vname" value="'+sViewName+'"/></td></tr>');
		Out('<tr><th>Enter select statement:</th></tr>');
		Out('<tr><td><textarea name="sql">');
		if(Request.Form("sql").Count==1) Out(Request.Form("sql").Item);
		Out('</textarea></td></tr>');

		Out('<tr><td><input type="submit" value="Test" name="test">\n');
		Out('<input type="submit" value="Create" name="create"></td></tr>\n');
		Out('</table>');
		
		if(Request.Form("test").Count==1) {
			try {
				var rs = Server.CreateObject("ADODB.Recordset");
			
				rs.Open(Request.Form("sql").Item,Object.Conn,adOpenStatic,adLockOptimistic,adCmdText);
				var Grid = new BGrid(rs);
				Grid.SetOption("pagesize",20);
				Grid.Process();
				rs.Requery();
				Out('<hr>');
				Grid.Display();
				Grid = null;

				rs.Close();
				rs = null;
			}
			catch(e) {
				Out('\n<s'+'cript type="text/javascript">\nSetErrorMessage("' + e.description + '");\n</scr'+'ipt>\n');
			}
		}

		Out('<br>');
		Out('<table class="list" cellspacing="0" cellpadding="0">\n');
		Out('<tr>\n');
  		Out('<td>&nbsp;<a href="list_views.asp">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

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