/ Published in: VB.NET

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Function CheckExistingUsername(ByVal username As String) As Boolean Dim UserExists As Boolean = False Dim strConn As String = System.Configuration.ConfigurationManager.ConnectionStrings("Fullconnection").ConnectionString Dim MySQL As String = "Select username from tUser where Username=@Username" Dim MyConn As New SqlConnection(strConn) Dim objDR As SqlDataReader Dim Cmd As New SqlCommand(MySQL, MyConn) Cmd.Parameters.Add(New SqlParameter("@Username", username)) Try MyConn.Open() objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection) While objDR.Read() UserExists = True End While Catch ex As Exception LogError("GlobalClass.vb :: CheckExistingUsername", ex.ToString) Finally CheckExistingUsername = UserExists End Try End Function
Comments
