Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 101 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
101
Dung lượng
47,08 MB
Nội dung
Trang B sp_DongTaiKhoanCucBo • CREATE PROCEDURE sp_DongTaiKhoanToanCuc @MaSoTaiKhoan varchar(15), @MaSoChiNhanh smallint, @NhanVienThucHien varchar(lO) AS - - - = =:J Trang 95 BEGIN Declare @SQLServerName varchar(50) Declare @TruyVan varchar(200) Select@SQLServerName = CN_SQLSERVERNAME From CHINHANH Where CN_MASO = @MaSoChiNhanh if(@SQLServerName is not null) Begin Select @TruyVan = '['+@SQLServerName+'].NGANHANG sp_DongTaiKhoanCucBo' Exec @TruyVan @MaSoTaiKhoan, @NhanVienThucHien End END GO 11 La-ythong tin tai khoan cue bo: sp ThongTinTaiKhoanCueBo - Input: + Ma sf) tai khoan, @MaSoTaiKhoan - Output: Khong co - Process: + TIm dung rna sf) tai khoan va + Select thong tin tai khoan • CREATE PROCEDURE sp_ThongTinTaiKhoanCucBo @MaSoTaiKhoanVarchar(15) AS BEGIN Select * From TAIKHOAN, LOAITIEN, TINHTRANG, CHINHANH, KHACHHANG Where TAIKHOAN.TK_MASO = @MaSoTaiKhoan and Trang 96 Phdnphl;lIl;lC TAIKHOAN.TK_CHU = KHACHHANG.KH_MASO AND TAIKHOAN.TK_TINHTRANG = TINHTRANG.TT_MASO AND TAIKHOAN.TK_LOAITIEN = LOAITIEN.LT_MASO AND TAIKHOAN.TK_CHINHANH = CHINHANH.CN_MASO END GO 12 La'y thong tin Hli khoan Tren chi nhanh ba't ky: sp ThongTinTaiKhoanToanCuc : - Input: + Ma sf) tai khocin, @MaSoTaiKhoan + Ma sf) chi nhanh cftn Ifty thong tin tai khoan, , @MaSoChiNhanh - Output: Khong c6 - Process: + Tim dung rna sf) chi nhanh truy€n vao + GQi thu tl;lcla'y thong tin tai khoan ClJCb9, sp_ ThongTinTaiKhoanCucBo CREATE PROCEDURE sp_ ThongTinTaiKhoanToanCuc @MaSoTaiKhoan Varchar(l5), @MaSoChiNhanhsmallintAS BEGIN Declare @SQLServerName varchar(50) Declare @TruyVan varchar(200) • Select @SQLServerName = CN_SQLSERVERNAME From CHINHANH Where CN_MASO = @MaSoChiNhanh • if(@SQLServerName Begin is not null) Trang 97 Phdnphl;t ll;tc Select @TruyVan = '['+@ SQLServerN ame+'] NGANHANG sp_ ThongTinTaiKhoanCucBo' Exec @TruyVan @MaSoTaiKhoan End END • GO 13 Visual Basic va Store Procedure voi tham s6 Output Store procedures co th~ chua tham s6 input, tham s6 output va gia tri tn1 v~ Ta co th~ xac dinh tham s6 output, tham s6 inphut va gia tri tra v~ cua store procedure thong qua d6i tu'Qng Parameter cua Visual Basic Trong tru'ong hQp tham s6 output va gia tri tni v~, gia trj khong du'Qctn1 v~ ne'u dli lit%ucua d6i tu'Qng Recordset khong du'Qcdem v~ trQn v~n (recordset.state = 0, khong co diu It%nhselect nao store procedure) ho~c Recordset bi dong '1111111111111 Test procedure with output , Declare some objects an some variables Dim cmd As New ADODB.Command Dim rs As New ADODB.Recordset Dim pI As Parameter 'Set up a command object for the store procedure cmd.ActiveConnection = conn cmd.CommandText = "sp_test" cmd.CommandType = adCmdStoredProc • • , Set up an output parameter Set pI = cmd.CreateParameter("Output", 15) cmd.Parameters.Append pI Set rs = cmd.Execute adVarChar, adParamOutput, Trang 98 Phanphl;lIl;lC If rs.State = Then GoTo het Dim fldloop As ADODB.Field Dim i As Integer While Not rs.EOF For Each fldloop In rs.Fields Debug.Print rs.Fields(i) i=i+ Next fldloop Debug.Print "" i= rs.MoveNext Wend het: Debug.Print "Ma So Khach Hang" & cmd(O) 14 Cae ham xli If Visual Basic a) Thil tf!,c chen dilli~u vao DataCombo Sub ins_DataComboChiNhanh( dcbChiNhanh As DataCombo) Set rsChiNhanh = conn.Execute(" Select * From CHINHANH") Set dcbChiNhanh.RowSource = rsChiNhanh dcbChiNhanh.ListField = "CN_MASO" dcbChiNhanh.BoundColumn = "CN_MASO" dcbChiNhanh.SelText = End Sub b) Thil tf!,c kiim Ira ky t~tllhljp vao ia so'? • Sub sub_KiemTraSo(keycode As Integer, text As TextBox) Trang 99 • • If Not ((keycode >= 48 And keycode = 96 And keycode