Advertisement
Guest User

Untitled

a guest
Oct 1st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rivate Sub ButtonSubmit_Click(sender As Object, e As EventArgs) Handles ButtonSubmit.Click
  2.         Dim sqlcon As New SqlConnection With {.ConnectionString = "Server=essql1.walton.uark.edu;Database=PROJF1703;User Id=PROJF1703; Password=NV43wg$;"}
  3.         Dim sqlcmd As SqlCommand
  4.         Dim query As String
  5.         Dim UserName As String
  6.         Dim SQLPassword As String
  7.         Dim GivenPassword As String
  8.  
  9.         query = "SELECT [UserName], [UserPassword] FROM Authenticate WHERE (UserName='" + TBUsername.Text + "')AND (UserPassword='" + TBPassword.Text + "');"
  10.         'query = "Select UserPassword FROM Authenticate WHERE UserName = '@accountName';"
  11.        '"INSERT INTO questions (question) VALUES (@question);"
  12.  
  13.         Try
  14.             sqlcon.Open()
  15.             sqlcmd = New SqlCommand(query, sqlcon)
  16.             Dim accountName As String = TBUsername.Text
  17.             'sqlcmd.Parameters.AddWithValue("@accountName", accountName)
  18.            sqlcmd.ExecuteNonQuery()
  19.             Dim reader As SqlDataReader = sqlcmd.ExecuteReader()
  20.             If reader.HasRows Then
  21.                 While reader.Read()
  22.                     SQLPassword = reader("UserPassword").ToString()
  23.                     UserName = reader("UserName").ToString()
  24.  
  25.                     GivenPassword = TBPassword.Text
  26.                     If SQLPassword = GivenPassword And UserName = TBUsername.Text Then
  27.                         Queries.Show()
  28.                     Else
  29.                         Form1.Show()
  30.                     End If
  31.  
  32.                 End While
  33.             End If
  34.  
  35.             Me.Close()
  36.         Catch ex As Exception
  37.             MsgBox(ex.Message)
  38.             Throw ex
  39.         Finally
  40.             If sqlcon.State = ConnectionState.Open Then
  41.             sqlcon.Close()
  42.         End If
  43.         End Try
  44.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement