Advertisement
imnotarobot13

In progress

Jan 19th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. Imports System.Data.OleDb
  2.  
  3. Public Class Form1
  4. Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:\CSDP\CP12\CP12 A\Midterm Don Antonio\MIDTERMDB.accdb"
  5. Public conn As New OleDbConnection
  6.  
  7. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8. conn.ConnectionString = connstring
  9. If conn.State = ConnectionState.Closed Then
  10. conn.Open()
  11.  
  12. End If
  13. End Sub
  14.  
  15. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  16. Dim sqlquery As String = "SELECT * from TABLEMIDTERM1 where USERNAME=@field1 and PASSWORD=@field2"
  17. Dim sqlcommand As New OleDbCommand
  18. With sqlcommand
  19. .CommandText = sqlquery
  20. .Connection = conn
  21. .Parameters.AddWithValue("@field1", TextBox1.Text)
  22. .Parameters.AddWithValue("@field2", TextBox2.Text)
  23. .ExecuteNonQuery()
  24.  
  25.  
  26.  
  27. End With
  28. Dim SqlRdr As OleDbDataReader
  29. SqlRdr = sqlcommand.ExecuteReader
  30. If (SqlRdr.Read()) Then
  31. MsgBox("Welcome to Black Mesa!")
  32. Else
  33. MsgBox("Try Again!")
  34. End If
  35. End Sub
  36.  
  37. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  38. TextBox1.Clear()
  39. TextBox2.Clear()
  40. End Sub
  41. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement