Click here to Skip to main content
15,897,704 members
Articles / Web Development / IIS

Universal Table Editor

Rate me:
Please Sign up or sign in to vote.
4.86/5 (117 votes)
11 May 2003 1.6M   12.3K   275  
Viewer and Editor for any table in any Database you can reach from your IIS/PWS.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>

<HEAD>
  <TITLE>Universal Table Editor</TITLE>
  <LINK REL="stylesheet" TYPE="text/css" HREF="ute.css">
</HEAD>

<BODY BGCOLOR="#FFFFFF" LINK="#0000A0" VLINK="#0000A0" ALINK="#0000A0">

<TABLE WIDTH="75%"><TR>
<TD>

<H1>UTE - Universal Table Editor</H1>

<H3>Very welcome to this small demo site of UTE.</H3>

<P>There are two ways to connect UTE to a database: 
<UL>
  <LI>Via ODBC, using a so alled <b>DSN connection</b>.
  <LI>Via OLEDB Provider, this means directly to the file, a so called <b>DSN-less connection</b>.
</UL>
</P>

<P>This demo uses the second way, the <b>DSN-less connection</b>. This has two advantages right now: you
don't need to setup an ODBC Data Source before you can start exploring UTE, and the second much
more important advantage is, that UTE is able to detect <B>PRIMARY KEY</B> fields correctly.</P>

<P>Due to for me unkown reasons there is no <i>working</i> way to detect <B>PRIMARY KEY</B> fields
when being connected via ODBC to a database, although there is a specified methode (which simply
doesn't do what it should!).</P>

<P>If you want to use an ODBC connection to your database to need to setup an ODBC Data Source
and modify the <B>UTE.INC</B> (line 32) accordingly.</P>

<P>Ok, here we start: these are all tables of the <B>TEST.MDB</B> database:

<UL>
  <LI><A HREF="ute.asp?name=Employees"><b>ute.asp?name=Employees</b></A>
  <LI><A HREF="ute.asp?name=OrderDetails"><b>ute.asp?name=OrderDetails</b></A>
  <LI><A HREF="ute.asp?name=Orders"><b>ute.asp?name=Orders</b></A>
  <LI><A HREF="ute.asp?name=Products"><b>ute.asp?name=Products</b></A>
</UL>
</P>

<BR>

<P>As already mentioned UTE is not able to detect <B>PRIMARY KEYS</B> when being connected to the database via ODBC. In this
case you are able to set the <B>PRIMARY KEYS</B> as additional parameters:
<UL>
  <LI><A HREF="ute.asp?name=OrderDetails&pkey1=OrderID&pkey2=ProductID"><b>ute.asp?name=OrderDetails&pkey1=OrderID&pkey2=ProductID</b></A>
</UL>
</P>

<P>Per default UTE sorts all fields in your table alphabetically where all PRIMARY KEYS will be displayed at the most left in 
<I>italic</I> style. If your don't want UTE to sort the fields you can use the following parameter. In this case you get the
fields displayed in the order as they are defined in the database.
<UL>
  <LI><A HREF="ute.asp?name=Employees&sorted=0"><b>ute.asp?name=Employees&sorted=0</b></A>
</UL>
</P>

<BR>

<P>That's all for the moment and for this small UTE demonstration. Don't forget to take a look at 
<A HREF="http://www.codeproject.com/asp/ute.asp"><b>http://www.codeproject.com/asp/ute.asp</b></A>
for the most recent version of UTE and the latest discussions.</P>

<P>Enjoy UTE !</P>

<P>Tom Wellige, <A HREF="mailto:tom@wellige.com"><b>mailto:tom@wellige.com</b></A>, 
<A HREF="http://www.wellige.com"><b>http://www.wellige.com</b></A><P>


<BR><BR><BR><BR>


<STYLE><!-- 
.cch1{background:#FFFFCC;} 
--></STYLE>
<P>The code to enumerate all table in your database looks like this:<P>
<pre><span class=cch1><font color=gray>&lt;UL&gt;
</font></span><i>&lt;%</i>
  <FONT COLOR=RED><B>Dim</B></FONT> db<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> rst
  <FONT COLOR=RED><B>Set</B></FONT> db <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> Server<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>CreateObject<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>"ADODB.Connection"</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
  <FONT COLOR=RED><B>Set</B></FONT> rst <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> Server<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>CreateObject<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>"ADODB.RecordSet"</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>

  db<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT><FONT COLOR=RED><B>Open</B></FONT> sDSN
  <FONT COLOR=RED><B>Set</B></FONT> rst <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> db<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>OpenSchema<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>20<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=GREEN><I>' adSchemaTables</I></FONT> 

  <FONT COLOR=GREEN><I>' Loop through the results
</I></FONT>  <FONT COLOR=RED><B>Do</B></FONT> Until rst<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>EOF
    <FONT COLOR=RED><B>If</B></FONT> rst<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>Fields<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>"TABLE_TYPE"</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> <FONT COLOR=PURPLE>"TABLE"</FONT> <FONT COLOR=RED><B>Then</B></FONT>
      Response<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT><FONT COLOR=RED><B>Write</B></FONT><FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>"&lt;LI&gt;&lt;A HREF="</FONT><FONT COLOR=PURPLE>"ute.asp?name="</FONT> <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;</FONT></FONT> rst<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>Fields<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>"TABLE_NAME"</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;</FONT></FONT> <FONT COLOR=PURPLE>""</FONT><FONT COLOR=PURPLE>"&gt;"</FONT> <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;</FONT></FONT> rst<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>Fields<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>"TABLE_NAME"</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;</FONT></FONT> <FONT COLOR=PURPLE>"&lt;/A&gt;"</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
    <FONT COLOR=RED><B>End</B></FONT> <FONT COLOR=RED><B>If</B></FONT>
    rst<FONT COLOR=BLUE SIZE=+1><B>.</B></FONT>MoveNext
  <FONT COLOR=RED><B>Loop</B></FONT>

  <FONT COLOR=RED><B>Set</B></FONT> rst <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> <FONT COLOR=RED><B>Nothing</B></FONT>
  <FONT COLOR=RED><B>Set</B></FONT> db <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> <FONT COLOR=RED><B>Nothing</B></FONT>
<i>%&gt;</i><span class=cch1><font color=gray>
&lt;/UL&gt;
</font></span></pre>

<br><br><br><br>

</TD></TR></TABLE>

</BODY>
</HTML>

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
CEO Student
Germany Germany
Tom is in software development for about 15 years. He started with a SHARP MZ80k in Basic and Assembly Language. After collecting some experiance on an ATARI 1040ST he bought his very first IBM XT 286 (incl. 287!) and started to program in Turbo Pascal. He became very familiar with Borland's Turbo Vision and over the last years did a lot of development in C++ (MFC), Visual Basic, VB Script, ASP and SQL. He currently works as senior consultant for Swyx Solutions GmbH, based in Dortmund, Germany.
His absolute favourite is Guinness Wink | ;-) Sláinte!

Comments and Discussions