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.SqlDa taReader
Dim sSQL As String
sSQL = "SELECT password from tbl_users WHERE (username ='" &
Trim(Me.txtUser Name.Text) & "')"
Dim oCommand As New SqlClient.SqlCo mmand()
Try
oCommand.Comman dText = sSQL
oCommand.Connec tion = DatabaseConnect ion
oCommand.Comman dType = CommandType.Tex t
oDR = oCommand.Execut eReader(Command Behavior.Single Result)
Dim intRA As Integer = oDR.RecordsAffe cted()
Catch oX As Exception
MessageBox.Show (oX.Message)
Finally
oCommand = Nothing
End Try
Thanks in advance,
Bill
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.SqlDa taReader
Dim sSQL As String
sSQL = "SELECT password from tbl_users WHERE (username ='" &
Trim(Me.txtUser Name.Text) & "')"
Dim oCommand As New SqlClient.SqlCo mmand()
Try
oCommand.Comman dText = sSQL
oCommand.Connec tion = DatabaseConnect ion
oCommand.Comman dType = CommandType.Tex t
oDR = oCommand.Execut eReader(Command Behavior.Single Result)
Dim intRA As Integer = oDR.RecordsAffe cted()
Catch oX As Exception
MessageBox.Show (oX.Message)
Finally
oCommand = Nothing
End Try
Thanks in advance,
Bill
Comment