Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Public cn As ADODB.Connection
  2. Public rs As ADODB.Record
  3.  
  4. Public Sub Conectar()
  5. Set cn = New ADODB.Connection
  6. Set rs = New ADODB.Recordset
  7. rs.CursorLocation = adUseClient
  8. ' cn.Open "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=gestvehicular;User=root;Password=123456;Option=3;"
  9. cn.Open "Provider=SQLNCLI10;Server=.;Database=Northwind;Trusted_Connection=yes;"
  10. End Sub
  11.  
  12. Public Sub Desconectar()
  13. On Local Error Resume Next
  14. rs.Close
  15. Set rs = Nothing
  16. cn.Close
  17. Set cn = Nothing
  18. End Sub
  19.  
  20. Public Function Existe(id As Integer) As Boolean
  21.  
  22.  
  23. On Error GoTo tratarError
  24. Dim cmd As New Command
  25. Conectar
  26. With cmd
  27. .ActiveConnection = cn
  28. .CommandText = "SELECT COUNT(*) FROM Employees WHERE EmployeeID=@id"
  29. .CommandType = adCmdText
  30. .NamedParameters = True
  31. .Parameters.Append .CreateParameter("@id", adInteger, adParamInput, , id)
  32. .Execute
  33. If (rs.EOF) Then
  34.  
  35. End With
  36. On Error GoTo 0
  37. Desconectar
  38. Exit Function
  39. tratarError:
  40. MsgBox Err.Description
  41. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement