線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1328
推到 Plurk!
推到 Facebook!

如何引用其他form 上 的SqlDataAdapter 和sqlConnection

尚未結案
will
中階會員


發表:176
回覆:135
積分:62
註冊:2002-04-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-06-07 15:22:46 IP:218.162.xxx.xxx 未訂閱
小弟在一個ASP.NET的Web Form (WebForm1.aspx)上設定好一組SqlDataAdapter 和sqlConnection後 小弟又增增了一個Web Form(WebForm2.aspx), 請用Webform2 如何才能使用Webform1上設好的SqlDataAdapter 和sqlConnection呢?
code6421
版主


發表:43
回覆:223
積分:208
註冊:2002-08-16

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-06-07 20:45:16 IP:220.135.xxx.xxx 未訂閱
引言: 小弟在一個ASP.NET的Web Form (WebForm1.aspx)上設定好一組SqlDataAdapter 和sqlConnection後 小弟又增增了一個Web Form(WebForm2.aspx), 請用Webform2 如何才能使用Webform1上設好的SqlDataAdapter 和sqlConnection呢?
create it. Just coding... Taiwan:http://code6421.ktop.com.tw China:http://home.hoolee.com/~code6421
------
Just codeing...
will
中階會員


發表:176
回覆:135
積分:62
註冊:2002-04-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-06-07 22:20:56 IP:218.162.xxx.xxx 未訂閱
Thank Code, You mean I can create WebForm1 in WebForm2? How can I do that? Can you give me some code?    
引言:
引言: 小弟在一個ASP.NET的Web Form (WebForm1.aspx)上設定好一組SqlDataAdapter 和sqlConnection後 小弟又增增了一個Web Form(WebForm2.aspx), 請用Webform2 如何才能使用Webform1上設好的SqlDataAdapter 和sqlConnection呢?
create it. Just coding... Taiwan:http://code6421.ktop.com.tw China:http://home.hoolee.com/~code6421
code6421
版主


發表:43
回覆:223
積分:208
註冊:2002-08-16

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-06-08 01:15:25 IP:220.135.xxx.xxx 未訂閱
1.change sqlDataAdapter and your typed DataSet to public. 2.add a InitInternal function,see below. public void InitInternal() { OnInit(null); } 3.in WebForm2.Page_Load. WebForm1 form1 = new WebForm1(); form1.InitInternal(); form1.sqlDataAdapter1.Fill(form1.dataSet21,"Customers"); DataGrid1.DataSource = form1.dataSet21; DataGrid1.DataMember = "Customers"; DataBind(); form1.Dispose(); another better way is create a component,then wrapper sqlDataAdapter, SqlConnection and DataSet. ps:you can drop&down any component to your component class, like a dataModule,but you still need create it, .NET don't have auto-create feature. Just coding... Taiwan:http://code6421.ktop.com.tw China:http://home.hoolee.com/~code6421 發表人 - code6421 於 2004/06/08 01:16:10 發表人 - code6421 於 2004/06/08 01:26:17
------
Just codeing...
will
中階會員


發表:176
回覆:135
積分:62
註冊:2002-04-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-06-08 13:51:07 IP:163.17.xxx.xxx 未訂閱
Thank Code and thank for your code.    Can you give us a example about creating a component which wrapper sqlDataAdapter,SqlConnection and DataSet?        
引言: 1.change sqlDataAdapter and your typed DataSet to public. 2.add a InitInternal function,see below. public void InitInternal() { OnInit(null); } 3.in WebForm2.Page_Load. WebForm1 form1 = new WebForm1(); form1.InitInternal(); form1.sqlDataAdapter1.Fill(form1.dataSet21,"Customers"); DataGrid1.DataSource = form1.dataSet21; DataGrid1.DataMember = "Customers"; DataBind(); form1.Dispose(); another better way is create a component,then wrapper sqlDataAdapter, SqlConnection and DataSet. ps:you can drop&down any component to your component class, like a dataModule,but you still need create it, .NET don't have auto-create feature. Just coding... Taiwan:http://code6421.ktop.com.tw China:http://home.hoolee.com/~code6421 發表人 - code6421 於 2004/06/08 01:16:10 發表人 - code6421 於 2004/06/08 01:26:17
系統時間:2024-05-21 6:23:02
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!