在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
--------------------- const C='Data Source=LocalHost"MSSQL;Initial Catalog=pubs;User ID=sa;Password=admin'; S='select * from employee'; procedure TmainForm.Button1_Click(sender: System.Object; e: System.EventArgs); var Adapter:SqlDataAdapter; Table:DataTable; begin Table:=DataTable.Create; Adapter:=SqlDataAdapter.Create(S,C); Adapter.Fill(Table); GridView1.DataSource:=Table; GridView1.DataBind; end; --------------------- Adapter Fill Two Table in DataSet and Show ----------------------------------------------- const C='Data Source=LocalHost"MSSQL;Initial Catalog=pubs;User ID=sa;Password=admin'; S='select * from employee;select * from jobs'; //Use ; to separator two Sentence procedure TmainForm.Button1_Click(sender: System.Object; e: System.EventArgs); var Adapter:SqlDataAdapter; TableSet:DataSet; begin Adapter:=SqlDataAdapter.Create(S,C); TableSet:= DataSet.Create; Adapter.Fill(TableSet); //---Show First Table GridView1.DataSource:=TableSet.Tables[0].DefaultView; GridView1.DataBind; //--Show Next Table GridView2.DataSource:=TableSet.Tables[1].DefaultView; GridView2.DataBind; end; -------------------------------------------------------------- GridView中如何进行数据过滤 --------------------------- const c_cnn='Data Source=LocalHost"MSSQL;Initial Catalog=Northwind;User ID=sa;Password=admin'; c_sel='select * from customers;select * from employees;select * from suppliers'; var sqlDA:SqlDataAdapter; DS:DataSet; procedure TDefault.Button1_Click(sender: System.Object; e: System.EventArgs); begin sqlDA:=SqlDataAdapter.Create(c_sel,c_cnn); DS:=DataSet.Create; sqlDA.Fill(DS); GridView1.DataSource:=DS; GridView1.DataBind; end; procedure TDefault.Button2_Click(sender: System.Object; e: System.EventArgs); begin DS.Tables[0].DefaultView.RowFilter:=TextBox1.Text; GridView1.DataSource:=DS.Tables[0].DefaultView; //注意这里需要再次进行数据Bind GridView1.DataBind; end; ----------------------------------- 如何做关系表? ----------------- const c_cnn='Data Source=LocalHost"MSSQL;Initial Catalog=Northwind;User ID=sa;Password=admin'; c_sel='select * from suppliers;select * from products'; var sqlDA:SqlDataAdapter; DS:DataSet; procedure TDefault.Page_Load(sender: System.Object; e: System.EventArgs); begin sqlDA:=SqlDataAdapter.Create(c_sel,c_cnn); DS:=DataSet.Create; sqlDA.Fill(DS); end; procedure TDefault.OnInit(e: EventArgs); begin // // Required for Designer support // InitializeComponent; inherited OnInit(e); end; procedure TDefault.Button1_Click(sender: System.Object; e: System.EventArgs); begin DS.Relations.Add('SupProd',DS.Tables[0].Columns['SupplierID'],DS.Tables[1].Columns['SupplierID']); //在这建立关系,关设置关系名称 GridView1.DataSource:=DS.Tables[0].DefaultView; GridView1.DataBind; DS.Tables[1].DefaultView.RowFilter:=DS.Tables[0].Columns['SupplierID'].ToString+'=1'; //检索第二张表的内容,不能做动态条件???? GridView2.DataSource:=DS.Tables[1].DefaultView; GridView2.DataBind; end; ---------如何读取WEB.Config里的数据库连接配置------------------- procedure TDefault.Button1_Click(sender: System.Object; e: System.EventArgs); var configurationAppSettings: System.Configuration.AppSettingsReader;//注意这个引用 s:string; begin configurationAppSettings := System.Configuration.AppSettingsReader.Create; //必须创建配置服务应用程序设置 s:=(string(configurationAppSettings.GetValue('SqlConnection1.ConnectionString', TypeOf(string)))); Response.Write(s); end; -------------------------------------------------------------------- 关于使用frame(模板文件) 1,Project->add->Other->ASP.netMaster Page 2,ContentPlaceHolder是保留区域,由用户去使用, 3,其它区域是必显区,可以把要继的东西放在这个区间 4,project->add->new->Other-ASP.net Content Page->在Master Page File上写上Master Page名称 OK ------------------------------------ http://design.yesky.com/homepage/414/2215914.shtml ------------------------------------------------- 超文本不显示下划线 ---------------------- <style type ="text/css"> <!- a:link{text-decoration:none} a:hover{text-decoration:none} a:visited{text-decoration:none} -> </style> ----------------------- 设超链色 ------------- <style> <!-- a:link { color: #0020FF; text-decoration: none;font-size: 9pt} a:visited { color:#0020FF; text-decoration: none;font-size: 9pt} a:hover { color: red; text-decoration: none;font-size: 9pt} --> </style> |
请发表评论