首 页 教育新闻课件中心论文中心教学教案试题中心语文专题综合下载技术教程公务员  
设为首页
加入收藏
联系我们
您当前的位置:中国教育资源网 -> 技术教程 -> 网站建设 -> 源码精华 -> 技术内容 退出登录 用户管理

SQL SERVER结构浏览器源码精华教程

论文作者:佚名  论文来源:不详  论文发布时间:2006-6-20 2:38:41  论文发布人:chjchjchj

减小字体 增大字体

日前,本编辑在TechTarget站浏览时,无意中发现了此代码,看了又看觉得甚是经典,遂拿出与众SQLer分享,欢迎交流。

<%@ LANGUAGE = J<I>script</I> %>
<%
<I>var</I> ConnStr= "DSN=admin"; //
<I>var</I> UserLogin= "sa"; // input empty Login and Password,
<I>var</I> UserPassword= ""; // if your DSN works via WinNT trust connection
<I>var</I> CharSet= "gb2312"; // as sample "windows-1251"
<I>var</I> PgSize= 10;
%>
<html>
<head>
<<I>meta</I> http-equiv="content-type" content="text/html; charset=<%=CharSet%>">
<title>MS SQL Structure Viewer Version 1.2</title>
</head>
<body bgcolor=#2f2f2f link=#000000 vlink=#000000 alink=#000000 topmargin=1 leftmargin=1>
<table width='100%' bgcolor=gray cellpadding=0 cellspacing=0><td>
<table width='100%' cellpadding=0 cellspacing=1>
<tr><td align=center>
<font color=white size=+1><b>MS SQL WebTools >> Table Structure Viewer</b></font></td>
<td align=right>
<font color=black><small><b>written by
<a href="mailto:little@ivc.tagmet.ru">
<font color=black><small><b>Alexander Tkalich</b></small></a></b></small></font>
</td></tr>
</table>
</td>
</table>
<p>
<%
<I>var</I> trColor1= "#7f9faf", trColor2= "#bfcfd7";
<I>var</I> trColor= trColor1;

<I>function</I> isDef( Value){
if( Value== ( Value+ "")) return true;
return false;
}

<I>function</I> QOutSelect( Conn, Name, Value, FirstName, FirstValue, SQL, SSize){
<I>var</I> Rs= Conn.Execute( SQL);
Response.Write( "<select name='"+ Name+ "' size="+ SSize+ ">");
if( FirstName!= "")
Response.Write( "<option value='"+ FirstValue+ "'>"+ FirstName);
for( ; !Rs.EOF; Rs.MoveNext()){
Id= Rs( 0);
Nm= Rs( 1);
if( Value== ""+ Id) S= 'selected'; else S= '';
Response.Write( "<option value='"+ Id+ "' "+ S+ ">"+ Nm+ "\n");
}
Response.Write( "</select>");
}

<I>var</I> S, DbName, TbName, Tbl, Row;
if( !isDef( DbName= Request.Form( "DbName")))
DbName= Request.QueryString( "DbName");
if( !isDef( TbId= Request.Form( "TbId")))
TbId= Request.QueryString( "TbId");
Tbl= Request.QueryString( "Tbl");
Row= Request.QueryString( "Row")/ 1;
%>

<center>

<%
<I>var</I> Conn= Server.CreateObject("ADODB.Connection");
Conn.Open( ConnStr, UserLogin, UserPassword);

if( !isDef( Tbl)){
%>

<form name='f' method=post action='TbStru.asp'>
<input type=hidden name=CurrentDb value='<%=DbName%>'>
<table border=1 bgcolor=#7f9faf cellpadding=0 cellspacing=0><td>
<table border=0 cellpadding=8 cellspacing=0><tr valign=bottom><td align=center><b>Databases</b><br>

<%
QOutSelect( Conn, "DbName' onChange='document.f.submit();", DbName, "", "",
"select name, name from master.dbo.sysdatabases Order by name", 10);
Response.Write( '</td>');
if( isDef( DbName)){
Response.Write( '<td align=center><b>Tables & Views</b><br>');
QOutSelect( Conn, "TbId' onChange='document.f.submit();", TbId, '', '',
"select id, name from "+ DbName+ ".dbo.sysobjects where type in ('U','V') and category<>2 Order By Name", 10);
Response.Write( '</td>');
}
if( isDef( DbName)) S= 'Show structure';
else S= 'Show list of tables';
Response.Write(
"\n<td><table height='100%' border=0>\n"+
"<tr valign=bottom><td><input type=submit value='"+ S+ "'></td></tr>\n"+
"</table></td></tr></table></td></table></form><p>\n"
);
}

if( !isDef( CurrentDb= Request.Form( "CurrentDb")))
CurrentDb= Request.QueryString( "CurrentDb");
if( !isDef( Tbl)&& isDef( DbName)&& DbName+ ""== CurrentDb+ ""&& isDef( TbId)){
Rs= Conn.Execute(
"select O.name, U.name"+
" from "+ DbName+ ".dbo.sysobjects O, "+
DbName+ ".dbo.sysusers U"+
" where O.id="+ TbId+ " and U.uid=O.uid"
);
TbName= Rs( 0);
TbOwner= Rs( 1);
Response.Write(
"<a target='_blank' href='TbStru.asp?Tbl=["+ DbName+ "].["+ TbOwner+ "].["+ TbName+ "]&TbId="+ TbId+
"&DbName="+ DbName+ "'>"+
"<font color=white><b>"+ DbName+ "."+ TbOwner+ "."+ TbName+ "</b></font></a>\n"
);
Response.Write( "<br>\n");
Rs= Conn.Execute(
"select C.name, T.name, C.length, C.xprec, C.xscale,"+
" C.colstat, C.isnullable,"+
" case when C.autoval is null then 0 else 1 end,"+
" SC.text, "+
"( select CForgin.name+ ' of '+ '<a href=\"TbStru.asp?"+
"DbName="+ DbName+ "&CurrentDb="+ DbName+
"&TbName='+ O.name+ '&TbId='+ Convert( <I>var</I>char, Sr.rkeyid)+ '"+
"\"><b>'+ O.name+ '</b></a>'"+
" from "+ DbName+ ".dbo.sysreferences Sr,"+
DbName+ ".dbo.sysobjects O,"+
DbName+ ".dbo.syscolumns CForgin"+
" where Sr.fkeyid="+ TbId+ " and Sr.fkey1=C.colid and Sr.rkeyid=O.id"+
" and CForgin.id=O.id and CForgin.colid=Sr.rkey1"+
") from "+ DbName+ ".dbo.syscolumns C, "+
DbName+ ".dbo.systypes T, "+
DbName+ ".dbo.syscomments SC "+
"where C.id="+ TbId+ " and C.xtype=T.xusertype and C.cdefault*=SC.id "+
"order by C.colid"
);
%>
<input type=hidden name=DbName value='<%=DbName%>'>
<input type=hidden name=CurrentDb value='<%=DbName%>'>
<input type=hidden name='TbId' value='<%=TbId%>'>
<table border=1 bordercolor=#5f5f5f bgcolor=#cfcfcf cellpadding=3 cellspacing=0>
<tr bgcolor=<%=trColor%>><th>Nn</th><th>Name</th><th>Type</th><th>length</th>
<th>precision</th><th>scale</th><th>default value</th><th>properties</th><th>relation</th></tr>
<%
for( TrColor= '', i= 1; !R
[] [返回上一页] [打 印] [收 藏]  
 ∷相关技术评论  (评论内容只代表网友观点,与本站立场无关!) [查看发表评论...]
 
 中国教育资源网免费技术教程下载中心-站内广告 站内广告 中国教育资源网免费技术教程下载中心-站内广告 
 中国教育资源网站内搜索 站内搜索 中国教育资源网站内搜索 
 

   
 中国教育资源网免费技术教程下载中心-栏目导航 栏目导航 中国教育资源网免费技术教程下载中心-栏目导航 
· Dreamweaver · FrontPage
· CSSHTML · DOMJS
· Google排名 · 搜索研究
· 网络赚钱 · Alexa相关
· 建站交流 · 源码精华
· 经验技巧
 
中国教育资源网免费技术教程下载中心-相关教程  相关技术 中国教育资源网免费技术教程下载中心-相关教程
· SQL SERVER实用经验
· SQL SERVER实用经验
· SQL SERVER实用经验
· SQL Server 存储过程
· PHP/MySQL Search E
· 用WEB(ASP)方式实现
· JBuilderX+SQL Serv
· 用DELPHI编程访问SQ
· Delphi处理SQL Serv
· Visual C#的SQL Ser
 中国教育资源网免费技术教程下载中心-本月热门教程 本月热门 中国教育资源网免费技术教程下载中心-本月热门教程 
 
 中国教育资源网免费技术教程下载中心-本日热门论文 本日热门 中国教育资源网免费技术教程下载中心-本日热门论文 
 
关于本站 - 网站帮助 - 免费课件 - 美容 - 绿色软件 - 软件下载 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 网站留言
浙ICP备06010405号 Email:cnkjz@163.com 技术支持:名流设计
版权所有 Copyright© 2002-2004 名流