|
<%@language=javascript%>
<!--#include file=common.asp-->
<!--#include file=b.func.asp-->
<%
function GetRecordCount(sTable) {
var sql, nRecords;
if(IsJet(Object.Conn))
sql = 'select count(1) from [' + sTable + ']';
else
sql = 'select count(1) from "' + sTable + '"';
var rs = Object.Conn.Execute(sql);
nRecords = rs(0).Value;
rs.Close();
rs = null;
return nRecords;
}
function Content() {
var oCat = Server.CreateObject("ADOX.Catalog");
var bViews = false;
oCat.ActiveConnection = Object.Conn;
var rsKeys = Object.Conn.OpenSchema(adSchemaForeignKeys);
Out('<table class="list" cellspacing="0" cellpadding="0">\n');
Out('<tr><th colspan="4">Tables</th><th>Commands</th><th>Records</th><th>Created</th><th>Modified</th><th>References</th><th>Referenced By</th></tr>\n');
for(var e = new Enumerator(oCat.Tables);!e.atEnd();e.moveNext()) {
var sRef = '';
var sRefBy = '';
var oTable = e.item();
if(oTable.Type=="VIEW") bViews = true;
if(oTable.Type!="TABLE") continue;
// Find references and referenced by
if(rsKeys.RecordCount>0) {
rsKeys.MoveFirst();
while(!rsKeys.EOF) {
if(rsKeys("FK_TABLE_NAME").Value == oTable.Name)
sRef += rsKeys("PK_TABLE_NAME").Value + ' ';
rsKeys.MoveNext();
}
rsKeys.MoveFirst();
while(!rsKeys.EOF) {
if(rsKeys("PK_TABLE_NAME").Value == oTable.Name)
sRefBy += rsKeys("FK_TABLE_NAME").Value + ' ';
rsKeys.MoveNext();
}
}
if(!sRef.length) sRef = ' ';
if(!sRefBy.length) sRefBy = ' ';
Out('<tr valign="top">\n');
Out('<td><img src="images/table.gif" align="absmiddle"/> <a href="data.asp?table='+oTable.Name+'">' + oTable.Name + '</a></td>\n');
Out('<td><a href="columns.asp?table='+oTable.Name+'">Columns</a></td>\n');
Out('<td><a href="indexes.asp?table='+oTable.Name+'">Indexes</a></td>\n');
Out('<td><a href="keys.asp?table='+oTable.Name+'">Keys</a></td>\n');
Out('<td><a href="javascript:TruncateTable(\''+oTable.Name+'\')">Truncate</a>');
Out(' | <a href="csv.asp?table='+oTable.Name+'">CSV</a>');
Out(' | <a href="javascript:DropTable(\''+oTable.Name+'\')">Drop</a></td>\n');
Out('<td align="right">'+GetRecordCount(oTable.Name)+'</td>\n');
Out('<td>'+jsFormatDateTime(oTable.DateCreated,2)+'</td>\n');
Out('<td>'+jsFormatDateTime(oTable.DateModified,2)+'</td>\n');
Out('<td>'+sRef+'</td>\n');
Out('<td>'+sRefBy+'</td>\n');
Out('</tr>');
}
Out('<tr><td colspan="10"><a href="createtable.asp">Create a new table</a></td></tr>\n');
Out('</table>\n');
rsKeys.Close();
rsKeys = null;
oCat = null;
Out('<br>');
Out('<table class="list" cellspacing="0" cellpadding="0">\n');
Out('<tr>\n');
Out('<td> <a href="list_views.asp">Views</a> </td>\n');
//Out('<td> <a href="list_procs.asp">Procedures</a> </td>\n');
//Out('<td> <a href="list_users.asp">Users</a> </td>\n');
Out('<td> <a href="schema.asp">Schemas</a> </td></tr>\n');
Out('</table>\n');
}
PageSetup();
NewPageHeader();
Content();
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.