Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. Dim vcStr As String = "Server=SERVERSQLEXPRESS;DataBase=GENERAL;User Id=sa;Password=12345;"
  2.  
  3.  
  4. Private Function Conectar(oCN As SqlConnection, vcStr As String) As Boolean
  5. Try
  6. If oCN.State = ConnectionState.Closed Then
  7. oCN.ConnectionString = vcStr
  8. oCN.Open()
  9. End If
  10. Catch ex As Exception
  11. Return False
  12. End Try
  13. Return True
  14. End Function
  15.  
  16. Public Function Find(iCodCF As Integer, iSequencia As Integer) As Boolean
  17. Dim vlOK As Boolean = False
  18. Dim oCN As New SqlConnection
  19. If Conectar(oCN, vcStr) = True Then
  20. Dim oCD As New SqlCommand
  21. oCD.Connection = oCN
  22. Dim vcQ As String = "SELECT * FROM Telefone" &
  23. " WHERE i_codcf = " & iCodCF &
  24. " AND i_sequencia = " & iSequencia
  25. oCD.CommandText = vcQ
  26. Dim oDR As SqlDataReader = oCD.ExecuteReader()
  27. If oDR.Read() Then
  28. ...
  29. ...
  30. ...
  31. vlOK = True
  32. Else
  33. ...
  34. vlOK = False
  35. End If
  36. oDR.Close()
  37. oCN.Close()
  38. End If
  39. Return vlOK
  40. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement