AnNguyen > 03-10-19, 06:43 PM
Private Sub Form_Load()
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
cn.ConnectionString = "Provider=SQLOLEDB;Data Source=Annnguyen;Initial Catalog=Data-steame-sql;UID=abc;PWD=123;"
cn.Open
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With cmd
.ActiveConnection = cn
.CommandText = "sl_ListHocSinh"
.CommandType = adCmdStoredProc
End With
With rs
.ActiveConnection = cn
.CursorType = adOpenForwardOnly
.CursorLocation = adUseServer
End With
Set rs = cmd.Execute
Set Me.Recordset = rs
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
CREATE PROCEDURE sl_ListHocSinh
AS
BEGIN
SELECT mahs
FROM tbHocSinh
END
ongke0711 > 03-10-19, 07:12 PM
AnNguyen > 03-10-19, 08:55 PM
ongke0711 > 04-10-19, 09:35 AM
ALTER PROCEDURE sl_ListHocSinh
@mahs varchar(20)
AS
BEGIN
SELECT mahs
FROM tbHocSinh
WHERE [mahs] = @mahs
END
cmd.Parameters.Append cmd.CreateParameter("mahs", adVarChar, adParamInput, 20, Me.txtMaHs)
AnNguyen > 04-10-19, 12:30 PM
ongke0711 > 04-10-19, 01:08 PM
AnNguyen > 04-10-19, 02:46 PM