Show Data With Store Procedure And RecordSet In VB6

0 comments
Show Data With Store Procedure And RecordSet In VB6
(Menampilkan Data Menggunakan Store Procedure dan RecordSet di VB6)

Private Sub GetDetailUser(UserID As String)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cm As ADODB.Command
Dim sql As String

    Set cn = New ADODB.Connection   'Important to set new or u'll get an error
    Set cm = New ADODB.Command
    Set rs = New ADODB.Recordset
    
    cn.Open (ActiveCn)              'ActiveCN = Connection String
    With cm
        .ActiveConnection = cn
        .CommandType = adCmdStoredProc
        .CommandText = "[databasename]..spGetUserDetail"
        
        'Create Parameter
        .Parameters.Append .CreateParameter("@UserID", adBigInt, adParamInput, , Val(UserID))
    End With
    
    Set rs = cm.Execute
    
    With Text1
        If Not rs.EOF Then  'Do Not User rs.RecordCount
            .Text = rs!Name & "" & vbNewLine
            .Text = rs!Position & "" & vbNewLine
        End If
    End With
    
    Set cm = Nothing
    Set rs = Nothing
    Set cn = Nothing
End Sub




Related Post :



0 comments:

Post a Comment

 
VB Source Code | © 2011 Design by DheTemplate.com and Theme 2 Blog

Find more free Blogger templates at DheTemplate.com - Daily Updates Free Blogger Templates