当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 获取数据库表结构

ASP.NET
HTML服务器控件介绍:HtmlInputFile控件
HTML服务器控件介绍:HtmlInputHidden控件
HTML服务器控件介绍:HtmlInputImage控件
HTML服务器控件介绍:HtmlInputRadioButton控件
HTML服务器控件介绍:HtmlInputText控件
HTML服务器控件介绍:HtmlSelect控件
HTML服务器控件介绍:HtmlTable控件
HTML服务器控件介绍:HtmlTableCell控件
HTML服务器控件介绍:HtmlTableRow控件
HTML服务器控件介绍:HtmlTextArea控件
Web服务器控件:AdRotator控件
Web服务器控件:Button控件
Web服务器控件:Calendar控件
Web服务器控件:CheckBox控件
Web服务器控件:CheckBoxList控件
Web服务器控件:DropDownList控件
Web服务器控件:HyperLink控件
Web服务器控件:Image控件
Web服务器控件:ImageButton控件
Web服务器控件:Label控件

ASP.NET 中的 获取数据库表结构


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 127 ::
收藏到网摘: n/a


DataSet ds=new DataSet();
System.Data.SqlClient.SqlConnection cnn=new System.Data.SqlClient.SqlConnection("server=(local);database=northwind;trusted_connection=yes") ;
cnn.Open();
System.Data.SqlClient.SqlCommand cmd=new System.Data.SqlClient.SqlCommand();
cmd.Connection=cnn;
cmd.CommandText="Select * from PersonDetails where 1<>1" ;
System.Data.SqlClient.SqlDataReader dr=cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection) ;this.dataGrid1.DataSource=dr.GetSchemaTable();cnn.Close();dr.Close();