【正文】
)+ ″order by 成績 ″ Rs(4)=″select * from 學(xué)生成績 where 成績 =″ + Chr(34)+ ″ 差 ″_Chr(34)+ ″order by 成績 ″ End Sub Private Sub McScore_SeriesSelected(Series as Integer,MouseFlags as _Integer,Cancel as Integer) SelectedSeries=Series End Sub 6 Private Sub McScore_PointSelected(Series as Integer,DataPoint as_Integer,MouseFlags as Integer,Cancel as Integer) SelectedSeries=Series End Sub Private Sub McScore_Db1Click() ′ 改變 ADO 控件的記錄源并刷新 =Rs(SeletedSeries) End Sub VB 做為快速應(yīng)用開發(fā)( RAD)工具越來越得到開發(fā)人員的認(rèn)可和接受。它對許 多 API(如 ODBC API、 SOCKET API 等等)的封裝使得編程變得簡單起來。同時,它支持集成開發(fā)環(huán)境下的可視化、事件驅(qū)動、面向?qū)ο蟮染幊烫攸c。下面,我們談?wù)勗?VB中調(diào)用存儲過程的實現(xiàn)方法及其注意事項。 我們知道, VB的數(shù)據(jù)庫編程有許多種方法,比如直接用 ODBC API 編程,這種方法靈活、高效,程序員可以實現(xiàn)對數(shù)據(jù)庫復(fù)雜的控制;也可以用 VB 中的數(shù)據(jù)對象,如 RDO(遠程數(shù)據(jù)對象)、 DAO(數(shù)據(jù)訪問對象)、 ADO( ActiveX 數(shù)據(jù)對象),這種方法實現(xiàn)起來方便、快捷,但靈活性較差一些。由于 存儲過程在實現(xiàn)數(shù)據(jù)封裝、隱藏以及代碼的預(yù)編譯、減少網(wǎng)絡(luò)負(fù)載、維護方便等優(yōu)點,所以被許多 RDBMS 和編程工具做支持。 VB中的各類數(shù)據(jù)對象也提供對存儲過程的支持。 我們以 ADO 為例來說明其實現(xiàn)的步驟 1. 創(chuàng)建、調(diào)試存儲過程。你可以在數(shù)據(jù)庫中也可以在其他外掛程序的支持下進行存儲過程的創(chuàng)建和調(diào)試工作。本例中的存儲過程代碼如下(使用 PUBS 的MS SQL 中的例子庫 ): CREATE PROCEDURE myprocedure @job_id smallint, 7 @job_lvl tinyint AS SELECT * FROM employee WHERE job_id @job_id AND job_lvl @job_lvl 2. 在 VB中生成一個新的工程,工程有一窗體,一個 COMMAND( NAME: COMMAND1) 按鈕,一個 MSFlexGrid( NAME: MSFlexGrid1)控件。 3. 創(chuàng)建連接 ADO connection; 4. 創(chuàng)建命令 ADO mand。 5. 創(chuàng)建參數(shù)并設(shè)置各個參數(shù)的屬性; 6. 執(zhí)行 ADO mand。 7. 對數(shù)據(jù)進行處理; MSFlexGrid 顯示查詢到的數(shù)據(jù) 8. 釋放連接,退出程序。 其中代碼如下: 在窗體中聲明以下變量: Dim n1 As ‘ 連接 Dim mymand As ‘ 命令 Dim parm_jobid As ‘ 參數(shù) 1 Dim parm_joblvl As ‘ 參數(shù) 2 Dim rstByQuery As ‘ 結(jié)果集 8 Dim strCnn As String ‘ 連接字符串 在窗體的 LOAD 事件中加入如下代碼: Set n1 = New ‘ 生成一個連接 strCnn = DSN=MYDSN。uid=sa。pwd= ‘ 創(chuàng)建的系統(tǒng)數(shù)據(jù)源 MYDSN 指向 PUBS 數(shù)據(jù)庫 strCnn ‘ 打開連接 在窗體的 UNLOAD 中的加入代碼如下: ‘ 關(guān)閉連接 Set n1 = Nothing ‘ 釋放連接 在按鈕中的代碼如下: Dim i As integer Dim j as integer Set parm_jobid = New Set mymand = New 39。 = name1 this line can be ommited = adInteger ‘ 9 外 文 原 文(二) Electric circuit exchange work and vb transfer database The result of the connection setup with circuit switching is the reservation of bandwidth all the way from the sender to the receiver. All packets follow this path. Among other properties, having all packets follow the same path means that they cannot arrive out of order. With packet switching there is no path , so different packets can follow different paths, depending on work conditions at the time they are sent. They may arrive out of order. Packet switching is more fault tolerant than circuit switching. In fact, that is why it was invented. If a switch goes down, all of the circuits using it are terminated and no more traffic can be sent on any of them. With Packet switching, packets can be routed around dead switches. Setting up a path in advance also opens up the possibility of reserving bandwidth in advance. If bandwidth is reserved, then when a packet arrives, it can be sent out immediately over the reserved bandwidth. With packet switching, no bandwidth is reserved, so packets may have to wait their turn to be forwarded. Having bandwidth reserved in advance means that no congestion can occur when a packet shows up (unless more packets show up than expected).On the other hand, when an attempt is made to establish a circuit, the attempt can fail due to congestion. Thus, congestion can occur at different times with circuit switching(at setup time) and packet switching(when packets are sent). If a circuit has been reserved for a particular user and there is no traffic to send, the bandwidth of that circuit is wasted. It cannot be used for other traffic. Packet switching does not waste bandwidth and thus is more efficient form a systemwide perspective. Understanding this tradeoff is crucial for prehending the difference between circuit switching and packet switching. The tradeoff is between guaranteed service and wasting resources versus not guaranteeing service and not wasting 10 resources. Packet switching uses storeandforward transmission. A packet is accumulated. in a router’s memory, then sent on to the next router. With circuit switching, the bits just flow through the wire continuously. The storeandforward technique adds delay. Another difference is that circuit switching is pletely transpare