代码说明:
这里是获取数据库2000元数据的类,如果其他数据库可参照文章1。
2.2 ColumnInfo.cs
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; /// <summary> /// ColumnInfo 的摘要说明 /// </summary> public class ColumnInfo { public ColumnInfo() { // // TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 列名 /// </summary> public string Name { get ; set ; } /// <summary> /// 数据类型 /// </summary> public string DataType { get ; set ; } /// <summary> /// 长度 /// </summary> public int Length { get ; set ; } /// <summary> /// 是否允许空 /// </summary> public bool Nullable { get ; set ; } /// <summary> /// 1 标识 /// </summary> public int Identity { get ; set ; } /// <summary> /// 1 标识种子 /// </summary> public int IdentitySeed { get ; set ; } /// <summary> /// 标识增量 /// </summary> public int IdentityIncrement { get ; set ; } /// <summary> /// 说明 /// </summary> public string ColumnDesc { get ; set ; } /// <summary> /// 默认值 /// </summary> public string DefaultValue { get ; set ; } } 代码说明:
数据库字段Model。
2.3 Default.aspx
<% @ Page Language = " C# " AutoEventWireup = " true " CodeFile = " Default.aspx.cs " Inherits = " _Default " %> < html > < head > < meta http - equiv = " Content-Type " content = " text/html; charset=gb2312 " > < meta name = " Generator " content = " Microsoft Word 11 (filtered) " > < title > 数据库文档 </ title > < style > <!-- /* Font Definitions */ @font - face { font - family: 宋体; panose - 1 : 2 1 6 0 3 1 1 1 1 1 ; } @font - face { font - family: 楷体_GB2312; panose - 1 : 2 1 6 9 3 1 1 1 1 1 ; } @font - face { font - family: " \@宋体 " ; panose - 1 : 2 1 6 0 3 1 1 1 1 1 ; } @font - face { font - family: " \@楷体_GB2312 " ; panose - 1 : 2 1 6 9 3 1 1 1 1 1 ; } /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm; margin - bottom: .0001pt; text - align: justify; text - justify: inter - ideograph; font - size: 10 .5pt; font - family: " Times New Roman " ; } p.MsoFooter, li.MsoFooter, div.MsoFooter { margin: 0cm; margin - bottom: .0001pt; layout - grid - mode: char ; font - size: 9 .0pt; font - family: " Times New Roman " ; } /* Page Definitions */ @page Section1 { size: 595 .3pt 841 .9pt; margin: 72 .0pt 90 .0pt 72 .0pt 90 .0pt; layout - grid: 15 .6pt; } div.Section1 { page: Section1; } -- ></ style > </ head > < body lang = " ZH-CN " style = ' text-justify-trim: punctuation ' > < div class = " Section1 " style = ' layout-grid: 15.6pt ' > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span lang = " EN-US " style = ' font-size: 42.0pt ' >& nbsp; </ span ></ p > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span lang = " EN-US " style = ' font-size: 42.0pt ' >& nbsp; </ span ></ p > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span style = ' font-size: 42.0pt; font-family: 楷体_GB2312 ' > 数据库文档 </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < p class = " MsoNormal " > < span lang = " EN-US " >& nbsp; </ span ></ p > < div align = " center " > < table class = " MsoTableGrid " border = " 1 " cellspacing = " 0 " cellpadding = " 0 " style = ' margin-left: 34.6pt; border - collapse: collapse; border: none ' > < tr style = ' height: 15.6pt ' > < td width = " 85 " valign = " top " style = ' width: 64.0pt; border: solid windowtext 1.0pt; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span style = ' font-family: 宋体 ' > 版本号 </ span ></ p > </ td > < td width = " 131 " valign = " top " style = ' width: 98.6pt; border: solid windowtext 1.0pt; border - left: none; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span style = ' font-family: 宋体 ' > 日期 </ span ></ p > </ td > < td width = " 132 " valign = " top " style = ' width: 98.65pt; border: solid windowtext 1.0pt; border - left: none; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span style = ' font-family: 宋体 ' > 负责人 </ span ></ p > </ td > < td width = " 132 " valign = " top " style = ' width: 98.65pt; border: solid windowtext 1.0pt; border - left: none; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span style = ' font-family: 宋体 ' > 备注 </ span ></ p > </ td > </ tr > < tr style = ' height: 15.6pt ' > < td width = " 85 " valign = " top " style = ' width: 64.0pt; border: solid windowtext 1.0pt; border - top: none; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span lang = " EN-US " > 0.1 </ span ></ p > </ td > < td width = " 131 " valign = " top " style = ' width: 98.6pt; border-top: none; border-left: none; border - bottom: solid windowtext 1 .0pt; border - right: solid windowtext 1 .0pt; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span lang = " EN-US " > 2009 - 9 - 9 </ span ></ p > </ td > < td width = " 132 " valign = " top " style = ' width: 98.65pt; border-top: none; border-left: none; border - bottom: solid windowtext 1 .0pt; border - right: solid windowtext 1 .0pt; padding: 0cm 5 .4pt 0cm 5 .4pt; height: 15 .6pt ' > < p class = " MsoNormal " align = " center " style = ' text-align: center ' > < span style = ' font-family: 宋体 ' > 农民伯伯 </ span ></ p > </ td > 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/584166,如需转载请自行联系原作者