Hi all,
I using Inline Sql statements to validate username and password against
sql server. I want to catch any errors from Sql server such as Username not
known, Password incorrect, etc. Is there anyway to do this? Below is the
code I'm using:
Dim oDR As SqlClient.SqlDataReader
Dim sSQL As String
sSQL = "SELECT password from tbl_users WHERE (username ='" &
Trim(Me.txtUserName.Text) & "')"
Dim oCommand As New SqlClient.SqlCommand()
Try
oCommand.CommandText = sSQL
oCommand.Connection = DatabaseConnection
oCommand.CommandType = CommandType.Text
oDR = oCommand.ExecuteReader(CommandBehavior.SingleResul t)
Dim intRA As Integer = oDR.RecordsAffected()
Catch oX As Exception
MessageBox.Show(oX.Message)
Finally
oCommand = Nothing
End Try
Thanks in advance,
Bill