1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Public Class Iseekyou_Users
Private _sqlConnectionString As String
Public Sub New()
_sqlConnectionString = ConfigurationManager.ConnectionStrings("bdd_users").ConnectionString
End Sub
Public Function UserNameExist(ByVal UserName As String) As Integer
Try
Dim conn As SqlConnection = Nothing
Dim cmd As SqlCommand = Nothing
Dim myreader As SqlDataReader = Nothing
Dim cpt As Integer = 0
Try
conn = New SqlConnection(_sqlConnectionString)
conn.Open()
cmd.Connection = conn
cmd.CommandText = "SELECT COUNT(*) FROM Users WHERE UserName='" & UserName & "'"
myreader = cmd.ExecuteReader
While myreader.Read
cpt = myreader.GetValue(0)
End While
Return cpt
Finally
If Not IsNothing(cmd) Then cmd.Dispose()
If Not IsNothing(conn) Then conn.Close() : conn = Nothing
End Try
Catch ex As Exception
Throw ex
End Try
End Function
End Class |
Partager