Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public cn As ADODB.Connection
- Public rs As ADODB.Record
- Public Sub Conectar()
- Set cn = New ADODB.Connection
- Set rs = New ADODB.Recordset
- rs.CursorLocation = adUseClient
- ' cn.Open "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=gestvehicular;User=root;Password=123456;Option=3;"
- cn.Open "Provider=SQLNCLI10;Server=.;Database=Northwind;Trusted_Connection=yes;"
- End Sub
- Public Sub Desconectar()
- On Local Error Resume Next
- rs.Close
- Set rs = Nothing
- cn.Close
- Set cn = Nothing
- End Sub
- Public Function Existe(id As Integer) As Boolean
- On Error GoTo tratarError
- Dim cmd As New Command
- Conectar
- With cmd
- .ActiveConnection = cn
- .CommandText = "SELECT COUNT(*) FROM Employees WHERE EmployeeID=@id"
- .CommandType = adCmdText
- .NamedParameters = True
- .Parameters.Append .CreateParameter("@id", adInteger, adParamInput, , id)
- .Execute
- If (rs.EOF) Then
- End With
- On Error GoTo 0
- Desconectar
- Exit Function
- tratarError:
- MsgBox Err.Description
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement