![Visual_C_數(shù)據(jù)綁定技術(shù)[1]_第1頁](http://file1.renrendoc.com/fileroot_temp2/2020-9/30/907a56c9-ea5d-4202-8e74-d890ed2e4521/907a56c9-ea5d-4202-8e74-d890ed2e45211.gif)
![Visual_C_數(shù)據(jù)綁定技術(shù)[1]_第2頁](http://file1.renrendoc.com/fileroot_temp2/2020-9/30/907a56c9-ea5d-4202-8e74-d890ed2e4521/907a56c9-ea5d-4202-8e74-d890ed2e45212.gif)
![Visual_C_數(shù)據(jù)綁定技術(shù)[1]_第3頁](http://file1.renrendoc.com/fileroot_temp2/2020-9/30/907a56c9-ea5d-4202-8e74-d890ed2e4521/907a56c9-ea5d-4202-8e74-d890ed2e45213.gif)
![Visual_C_數(shù)據(jù)綁定技術(shù)[1]_第4頁](http://file1.renrendoc.com/fileroot_temp2/2020-9/30/907a56c9-ea5d-4202-8e74-d890ed2e4521/907a56c9-ea5d-4202-8e74-d890ed2e45214.gif)
![Visual_C_數(shù)據(jù)綁定技術(shù)[1]_第5頁](http://file1.renrendoc.com/fileroot_temp2/2020-9/30/907a56c9-ea5d-4202-8e74-d890ed2e4521/907a56c9-ea5d-4202-8e74-d890ed2e45215.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、Visual C#中的數(shù)據(jù)綁定Visual C自身沒有類庫,和其他的.Net開發(fā)語言一樣,Visual C#調(diào)用的類庫是.Net框架中的一個共有的類庫-.Net FrameWork SDK。ADO.NET是.Net FrameWork SDK提供給.Net開發(fā)語言進行數(shù)據(jù)庫開發(fā)的一個系列類庫的集合。在ADO.NET中雖然提供了大量的用于數(shù)據(jù)庫連接、數(shù)據(jù)處理的類庫,但卻沒有提供類 似DbText組件、DbList組件、DbLable組件、DbCombox組件等。要想把數(shù)據(jù)記錄以ComBox、ListBox等形式顯示處理,使 用數(shù)據(jù)綁定技術(shù)是最為方便、最為直接的方法。所謂數(shù)據(jù)綁定技術(shù)就是把已經(jīng)打開
2、的數(shù)據(jù)集中某個或者某些字段綁定到組件的某些屬性上面的一種技術(shù)。說的具體 些,就是把已經(jīng)打開數(shù)據(jù)的某個或者某些字段綁定到Text組件、ListBox組件、ComBox等組件上的能夠顯示數(shù)據(jù)的屬性上面。當(dāng)對組件完成數(shù)據(jù)綁 定后,其顯示字段的內(nèi)容將隨著數(shù)據(jù)記錄指針的變化而變化。這樣程序員就可以定制數(shù)據(jù)顯示方式和內(nèi)容,從而為以后的數(shù)據(jù)處理作好準(zhǔn)備。所以說數(shù)據(jù)綁定是 Visual C進行數(shù)據(jù)庫方面編程的基礎(chǔ)和最為重要的第一步。只有掌握了數(shù)據(jù)綁定方法,才可以十分方便對已經(jīng)打開的數(shù)據(jù)集中的記錄進行瀏覽、刪除、插入等具體的數(shù)據(jù) 操作、處理。 (下載源碼就到源碼網(wǎng):)數(shù)據(jù)綁定根據(jù)不
3、同組件可以分為二種,一種是簡單型的數(shù)據(jù)綁定,另外一種就是復(fù)雜型的數(shù)據(jù)綁定。所謂簡單型的數(shù)據(jù)綁定就是綁定后組 件顯示出來的字段只是單個記錄,這種綁定一般使用在顯示單個值的組件上,譬如:TextBox組件和Label組件。而復(fù)雜型的數(shù)據(jù)綁定就是綁定后的組件 顯示出來的字段是多個記錄,這種綁定一般使用在顯示多個值的組件上,譬如:ComBox組件、ListBox組件等。本文就是來詳細介紹如何用 Visual C實現(xiàn)這二種綁定。在數(shù)據(jù)庫的選擇上,為了使內(nèi)容更加全面,采用了當(dāng)下比較流行的二種數(shù)據(jù)庫,一種是本地數(shù)據(jù)庫Acess 2000,另外一種是遠程數(shù)據(jù)庫Sql Server 2000。一、本文程序設(shè)計和
4、運行的軟件環(huán)境(1)微軟公司視窗2000服務(wù)器版(2).Net FrameWork SDK Beta 2(3)MADC 2.6(Microsoft Acess Data Component)以上版本二、程序中使用的數(shù)據(jù)庫的數(shù)據(jù)字典(1)本地數(shù)據(jù)庫Access 2000的數(shù)據(jù)庫的名稱為db.mdb,在這個數(shù)據(jù)庫中定義了一張表person。這張表的數(shù)據(jù)結(jié)構(gòu)如下表:字段名稱字段類型字段意思id數(shù)字序號xm文本姓名xb文本性別nl文本年齡zip文本郵政編碼(2)遠程數(shù)據(jù)庫Sql Server 2000的數(shù)據(jù)庫服務(wù)器名稱為Server1,數(shù)據(jù)庫名稱為Data1,登陸的ID為sa,口令為空,在數(shù)據(jù)庫也定義
5、了一張person表,數(shù)據(jù)結(jié)構(gòu)如上表。三、數(shù)據(jù)綁定一般步驟(一)無論是簡單型的數(shù)據(jù)綁定,還是復(fù)雜型的數(shù)據(jù)綁定,要實現(xiàn)綁定的第一步就是就是要連接數(shù)據(jù)庫,得到可以操作的DataSet。下面二段代碼是分別連接Access 2000和Sql Server 2000數(shù)據(jù)庫,并獲得DataSet。 (下載源碼就到源碼網(wǎng):)(1)連接Access 2000,得到DataSet:/創(chuàng)建一個 OleDbConnection string strCon = Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = db.mdb ; OleD
6、bConnection myConn = new OleDbConnection ( strCon ) ; string strCom = SELECT * FROM person ; file:/創(chuàng)建一個 DataSet myDataSet = new DataSet ( ) ; myConn.Open ( ) ; file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/把Dataset綁定person數(shù)據(jù)表 myCommand
7、.Fill ( myDataSet , person ) ; file:/關(guān)閉此OleDbConnection myConn.Close ( ) ;(2)連接Sql Server 2000,得到DataSet:/ 設(shè)定數(shù)據(jù)連接字符串,此字符串的意思是打開Sql server數(shù)據(jù)庫, 服務(wù)器名稱為server1,數(shù)據(jù)庫為data1 string strCon = Provider = SQLOLEDB.1 ; Persist Security Info = False ; User ID = sa ; Initial Catalog = data1 ; Data Source = server1
8、 ; OleDbConnection myConn = new OleDbConnection ( strCon ) ; myConn.Open ( ) ; string strCom = SELECT * FROM person ; file:/創(chuàng)建一個 DataSet myDataSet = new DataSet ( ) ; file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/把Dataset綁定person數(shù)據(jù)表 my
9、Command.Fill ( myDataSet , person ) ; file:/關(guān)閉此OleDbConnection myConn.Close ( ) ;(二)根據(jù)不同組件,采用不同的數(shù)據(jù)綁定: 對于簡單型的數(shù)據(jù)綁定,數(shù)據(jù)綁定的方法其實比較簡單,在得到數(shù)據(jù)集以后,一般是通過把數(shù)據(jù)集中 的某個字段綁定到組件的顯示屬性上面,譬如TextBox組件和Label組件,是綁定到Text屬性。對于復(fù)雜型的數(shù)據(jù)綁定一般是通過設(shè)定其某些屬 性值來實現(xiàn)綁定的。這些下面將會具體介紹。四、簡單型組件的數(shù)據(jù)綁定: (1)TextBox組件的數(shù)據(jù)綁定: 通過下列語句就可以把數(shù)據(jù)集(即為:myDataSet)的某
10、個字段綁定到TextBox組件的“Text”屬性上面了:textBox1.DataBindings.Add ( Text , myDataSet , person.xm ) ;注釋:此時綁定是Access 2000數(shù)據(jù)庫中person表的xm字段。 由此可以得到綁定TextBox組件的源程序代碼(TextBox01.cs),下列代碼操作的數(shù)據(jù)庫是Access 2000,如下:public class Form1 : Form private TextBox textBox1 ; private Button button1 ; private System.Data.DataSet myDat
11、aSet ; private System.ComponentModel.Container components = null ; public Form1 ( ) file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集 GetConnect ( ) ; InitializeComponent ( ) ; file:/清除程序中使用過的資源 protected override void Dispose ( bool disposing ) if ( disposing ) if ( components != null ) components.Dispose ( ) ; base.Dispose ( di
12、sposing ) ; private void GetConnect ( ) file:/創(chuàng)建一個 OleDbConnection string strCon = Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = db.mdb ; OleDbConnection myConn = new OleDbConnection ( strCon ) ; string strCom = SELECT * FROM person ; file:/創(chuàng)建一個 DataSet myDataSet = new DataSet ( ) ; myConn.Open
13、 ( ) ; file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/把Dataset綁定person數(shù)據(jù)表 myCommand.Fill ( myDataSet , person ) ; file:/關(guān)閉此OleDbConnection myConn.Close ( ) ; private void button1_Click ( object sender , System.EventArgs e ) textBox1.Dat
14、aBindings.Add ( Text , myDataSet , person.xm ) ; static void Main ( ) Application.Run ( new Form1 ( ) ) ; 得到TextBox組件對本地數(shù)據(jù)庫中的字段進行數(shù)據(jù)綁定的程序后,可以方便的得到對遠程數(shù)據(jù)庫中的某些字段進行數(shù)據(jù)綁定的源程序代碼(TextBox02.cs),具體如下:public class Form1 : Form private TextBox textBox1 ; private Button button1 ; private System.Data.DataSet myDat
15、aSet ; private System.ComponentModel.Container components = null ; public Form1 ( ) file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集 GetConnect ( ) ; InitializeComponent ( ) ; file:/清除程序中使用過的資源 protected override void Dispose ( bool disposing ) if ( disposing ) if ( components != null ) components.Dispose ( ) ; base.Dispose ( di
16、sposing ) ; private void GetConnect ( ) / 設(shè)定數(shù)據(jù)連接字符串,此字符串的意思是打開Sql server數(shù)據(jù)庫,服務(wù)器名稱為server1,數(shù)據(jù)庫為data1 string strCon = Provider = SQLOLEDB.1 ; Persist Security Info = False ; User ID = sa ; Initial Catalog = data1 ; Data Source = server1 ; OleDbConnection myConn = new OleDbConnection ( strCon ) ; myCon
17、n.Open ( ) ; string strCom = SELECT * FROM person ; file:/創(chuàng)建一個 DataSet myDataSet = new DataSet ( ) ; file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/把Dataset綁定person數(shù)據(jù)表 myCommand.Fill ( myDataSet , person ) ; file:/關(guān)閉此OleDbConnection myC
18、onn.Close ( ) ; private void button1_Click ( object sender , System.EventArgs e ) textBox1.DataBindings.Add ( Text , myDataSet , person.xm ) ; static void Main ( ) Application.Run ( new Form1 ( ) ) ; (2)Label組件的數(shù)據(jù)綁定: 在掌握了TextBox組件數(shù)據(jù)綁定以后,可以十分方便的得到Label組件的數(shù)據(jù)綁定方法,因為這二者實現(xiàn)的方法實在是太相似了。下列語句是把得到數(shù)據(jù)集的xm字段綁定到La
19、bel組件的“Text”屬性上:label1.DataBindings.Add ( Text , myDataSet , person.xm ) ;注釋:此時綁定是Access 2000數(shù)據(jù)庫中person表的xm字段。由此可以得到Label組件數(shù)據(jù)綁定的源程序代碼(Label01.cs),本代碼操作數(shù)據(jù)庫是Access 2000:public class Form1 : Form private Label label1 ; private Button button1 ; private System.Data.DataSet myDataSet ; private System.Comp
20、onentModel.Container components = null ; public Form1 ( ) file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集 GetConnect ( ) ; InitializeComponent ( ) ; file:/清除程序中使用過的資源 protected override void Dispose ( bool disposing ) if ( disposing ) if ( components != null ) components.Dispose ( ) ; base.Dispose ( disposing ) ; private void G
21、etConnect ( ) file:/創(chuàng)建一個 OleDbConnection string strCon = Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = db.mdb ; OleDbConnection myConn = new OleDbConnection ( strCon ) ; string strCom = SELECT * FROM person ; file:/創(chuàng)建一個 DataSet myDataSet = new DataSet ( ) ; myConn.Open ( ) ; file:/用 OleDbDataAd
22、apter 得到一個數(shù)據(jù)集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/把Dataset綁定person數(shù)據(jù)表 myCommand.Fill ( myDataSet , person ) ; file:/關(guān)閉此OleDbConnection myConn.Close ( ) ; private void button1_Click ( object sender , System.EventArgs e ) label1.DataBindings.Add ( Text , myDat
23、aSet , person.xm ) ; static void Main ( ) Application.Run ( new Form1 ( ) ) ; 得到了Label組件對Access 2000數(shù)據(jù)庫數(shù)據(jù)綁定的程序代碼,改換一下程序中數(shù)據(jù)鏈接,就可以得到Label組件對Sql Server 2000數(shù)據(jù)庫數(shù)據(jù)綁定的源程序代碼(Label02.cs),具體如下:public class Form1 : Form private Label label1 ; private Button button1 ; private System.Data.DataSet myDataSet ; pr
24、ivate System.ComponentModel.Container components = null ; public Form1 ( ) file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集 GetConnect ( ) ; InitializeComponent ( ) ; file:/清除程序中使用過的資源 protected override void Dispose ( bool disposing ) if ( disposing ) if ( components != null ) components.Dispose ( ) ; base.Dispose ( disposing )
25、 ; private void GetConnect ( ) / 設(shè)定數(shù)據(jù)連接字符串,此字符串的意思是打開Sql server數(shù)據(jù)庫,服務(wù)器名稱為server1,數(shù)據(jù)庫為data1 string strCon = Provider = SQLOLEDB.1 ; Persist Security Info = False ; User ID = sa ; Initial Catalog = data1 ; Data Source = server1 ; OleDbConnection myConn = new OleDbConnection ( strCon ) ; myConn.Open (
26、) ; string strCom = SELECT * FROM person ; file:/創(chuàng)建一個 DataSet myDataSet = new DataSet ( ) ; file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/把Dataset綁定person數(shù)據(jù)表 myCommand.Fill ( myDataSet , person ) ; file:/關(guān)閉此OleDbConnection myConn.Close
27、 ( ) ; private void button1_Click ( object sender , System.EventArgs e ) label1.DataBindings.Add ( Text , myDataSet , person.xm ) ; static void Main ( ) Application.Run ( new Form1 ( ) ) ; 五、復(fù)雜型組件的數(shù)據(jù)綁定:在上面的介紹中,了解到對復(fù)雜型組件的數(shù)據(jù)綁定是通過設(shè)定組件的某些屬性來完成數(shù)據(jù)綁定的。首先來介紹一下ComboBox組件的數(shù)據(jù)綁定。(下載源碼就到源碼網(wǎng):)(1).C
28、omboBox組件的數(shù)據(jù)綁定:在得到數(shù)據(jù)集后,只有設(shè)定好ComboBox組件的的三個屬性就可以完成數(shù)據(jù)綁定了,這三個屬性是:DisplayMember、 ValueMember。其中DataSource是要顯示的數(shù)據(jù)集,DisplayMember是ComboBox組件顯示的字段, ValueMember是實際使用值。具體如下:ComboBox1.DataSource = myDataSet ;ComboBox1.DisplayMember = person.xm ;ComboBox1.ValueMember = person.xm ;注釋:此時綁定是Access 2000數(shù)據(jù)庫中person表
29、的xm字段。由此可以得到ComboBox組件數(shù)據(jù)綁定的源程序代碼(Combo01.cs),本代碼操作數(shù)據(jù)庫是Access 2000:public class Form1 : Formprivate ComboBox ComboBox1 ;private Button button1 ;private System.Data.DataSet myDataSet ;private System.ComponentModel.Container components = null ;public Form1 ( )file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集GetConnect ( ) ;Initializ
30、eComponent ( ) ;file:/清除程序中使用過的資源protected override void Dispose ( bool disposing )if ( disposing )if ( components != null ) components.Dispose ( ) ;base.Dispose ( disposing ) ;private void GetConnect ( )file:/創(chuàng)建一個 OleDbConnectionstring strCon = Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = db.
31、mdb ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;string strCom = SELECT * FROM person ;file:/創(chuàng)建一個 DataSetmyDataSet = new DataSet ( ) ;myConn.Open ( ) ;file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ;file:/把Dataset綁定person數(shù)據(jù)表myComman
32、d.Fill ( myDataSet , person ) ;file:/關(guān)閉此OleDbConnectionmyConn.Close ( ) ;private void button1_Click ( object sender , System.EventArgs e )ComboBox1.DataSource = myDataSet ;ComboBox1.DisplayMember = person.xm ;ComboBox1.ValueMember = person.xm ;static void Main ( ) Application.Run ( new Form1 ( ) ) ;
33、得到了ComboBox組件對本地數(shù)據(jù)庫的數(shù)據(jù)綁定程序,也就十分方便的得到ComboBox組件綁定Sql Server 2000源程序代碼(Combox02.cs)具體如下:public class Form1 : Formprivate ComboBox ComboBox1 ;private Button button1 ;private System.Data.DataSet myDataSet ;private System.ComponentModel.Container components = null ;public Form1 ( )file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集GetCo
34、nnect ( ) ;InitializeComponent ( ) ;file:/清除程序中使用過的資源protected override void Dispose ( bool disposing )if ( disposing )if ( components != null ) components.Dispose ( ) ;base.Dispose ( disposing ) ;private void GetConnect ( )/ 設(shè)定數(shù)據(jù)連接字符串,此字符串的意思是打開Sql server數(shù)據(jù)庫,服務(wù)器名稱為server1,數(shù)據(jù)庫為data1string strCon = P
35、rovider = SQLOLEDB.1 ; Persist Security Info = False ; User ID = sa ; Initial Catalog = data1 ; Data Source = server1 ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;myConn.Open ( ) ;string strCom = SELECT * FROM person ;file:/創(chuàng)建一個 DataSetmyDataSet = new DataSet ( ) ;file:/用 OleDbDataAdapt
36、er 得到一個數(shù)據(jù)集OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ;file:/把Dataset綁定person數(shù)據(jù)表myCommand.Fill ( myDataSet , person ) ;file:/關(guān)閉此OleDbConnectionmyConn.Close ( ) ;private void button1_Click ( object sender , System.EventArgs e )ComboBox1.DataSource = myDataSet ;ComboBox1.Disp
37、layMember = person.xm ;ComboBox1.ValueMember = person.xm ;static void Main ( ) Application.Run ( new Form1 ( ) ) ;(2)ListBox組件的數(shù)據(jù)綁定: ListBox組件的數(shù)據(jù)綁定和ComboBox組件的數(shù)據(jù)綁定的方法大致相同,也是通過設(shè)定DisplayMember、 ValueMember。其中DataSource這三個屬性來完成的。并且這三個屬性在ListBox組件中代表的意思和ComboBox組件 的意思基本一樣。由此可以得到ListBox組件對本地數(shù)據(jù)庫和遠程數(shù)據(jù)庫進行數(shù)據(jù)
38、綁定的源程序。其中ListBox01.cs是對本地數(shù)據(jù)庫進行數(shù)據(jù)綁 定,ListBox02.cs是對遠程數(shù)據(jù)庫進行數(shù)據(jù)綁定,具體如下:ListBox01.cs源程序代碼節(jié)選:public class Form1 : Formprivate ListBox ListBox1 ;private Button button1 ;private System.Data.DataSet myDataSet ;private System.ComponentModel.Container components = null ;public Form1 ( )file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集GetCon
39、nect ( ) ;InitializeComponent ( ) ;file:/清除程序中使用過的資源protected override void Dispose ( bool disposing )if ( disposing )if ( components != null ) components.Dispose ( ) ;base.Dispose ( disposing ) ;private void GetConnect ( )file:/創(chuàng)建一個 OleDbConnectionstring strCon = Provider = Microsoft.Jet.OLEDB.4.0
40、; Data Source = db.mdb ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;string strCom = SELECT * FROM person ;file:/創(chuàng)建一個 DataSetmyDataSet = new DataSet ( ) ;myConn.Open ( ) ;file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ;file:/把Dataset
41、綁定person數(shù)據(jù)表myCommand.Fill ( myDataSet , person ) ;file:/關(guān)閉此OleDbConnectionmyConn.Close ( ) ;private void button1_Click ( object sender , System.EventArgs e )ListBox1.DataSource = myDataSet ;ListBox1.DisplayMember = person.xm ;ListBox1.ValueMember = person.xm ;static void Main ( ) Application.Run ( n
42、ew Form1 ( ) ) ;以下代碼是ListBox組件對Sql Server 2000數(shù)據(jù)庫進行數(shù)據(jù)綁定的源程序節(jié)選(ListBox02.cs):private ListBox ListBox1 ;private Button button1 ;private System.Data.DataSet myDataSet ;private System.ComponentModel.Container components = null ; public Form1 ( )file:/打開數(shù)據(jù)鏈接,得到數(shù)據(jù)集GetConnect ( ) ;InitializeComponent ( ) ;
43、file:/清除程序中使用過的資源protected override void Dispose ( bool disposing )if ( disposing )if ( components != null ) components.Dispose ( ) ;base.Dispose ( disposing ) ;private void GetConnect ( )/ 設(shè)定數(shù)據(jù)連接字符串,此字符串的意思是打開Sql server數(shù)據(jù)庫,服務(wù)器名稱為server1,數(shù)據(jù)庫為data1string strCon = Provider = SQLOLEDB.1 ; Persist Secur
44、ity Info = False ; User ID = sa ; Initial Catalog = data1 ; Data Source = server1 ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;myConn.Open ( ) ;string strCom = SELECT * FROM person ;file:/創(chuàng)建一個 DataSetmyDataSet = new DataSet ( ) ;file:/用 OleDbDataAdapter 得到一個數(shù)據(jù)集OleDbDataAdapter myCommand
45、 = new OleDbDataAdapter ( strCom , myConn ) ;file:/把Dataset綁定person數(shù)據(jù)表myCommand.Fill ( myDataSet , person ) ;file:/關(guān)閉此OleDbConnectionmyConn.Close ( ) ;private void button1_Click ( object sender , System.EventArgs e )ListBox1.DataSource = myDataSet ;ListBox1.DisplayMember = person.xm ;ListBox1.ValueMember = person.xm ;static void Main ( ) Application.Run ( new Form1 (
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年醫(yī)學(xué)高級職稱-中醫(yī)耳鼻喉科(醫(yī)學(xué)高級)歷年參考題庫含答案解析(5卷單選100題)
- 智能算法驅(qū)動的資產(chǎn)證券化風(fēng)險管理-洞察及研究
- 2025年住院醫(yī)師規(guī)范培訓(xùn)(各省)-廣西住院醫(yī)師眼科歷年參考題庫含答案解析(5卷單選一百題)
- 2025-2030光學(xué)加工機械行業(yè)市場運行態(tài)勢分析及前景趨勢與投資研究報告
- 2025-2030中國非接觸式轉(zhuǎn)速計行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 2025-2030中國醋酸月桂酯(CAS 112-66-3)行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 2025年住院醫(yī)師規(guī)范培訓(xùn)(各省)-四川住院醫(yī)師外科學(xué)歷年參考題庫含答案解析(5卷單項選擇題100題)
- 2025-2030中國負載組租賃服務(wù)行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 2025-2030中國硅酸材料行業(yè)市場現(xiàn)狀供需分析及重點企業(yè)投資評估規(guī)劃分析研究報告
- 【真題】人教版二年級下冊期末測試數(shù)學(xué)試卷(含解析)2024-2025學(xué)年湖南省長沙市寧鄉(xiāng)市
- 低鉀血癥完整版本
- 2024年秘書證考試法律法規(guī)試題及答案
- 初中八年級英語閱讀理解及答案
- 2024年08月浙江廣發(fā)銀行杭州分行招考筆試歷年參考題庫附帶答案詳解
- 婦產(chǎn)科護理技能實訓(xùn) 課件 1.1.2陰道灌洗技術(shù)
- 財務(wù)總監(jiān)崗位面試題及答案(經(jīng)典版)
- 手術(shù)室低值耗材成本管理
- 2024年無人駕駛環(huán)衛(wèi)行業(yè)研究報告
- 制造業(yè)的綠色生產(chǎn)與可持續(xù)發(fā)展考核試卷
- DB32T 1590-2010 鋼管塑料大棚(單體)通 用技術(shù)要求
- 阿片類藥物不良反應(yīng)綜合防治專家共識(2024年版)
評論
0/150
提交評論