Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.OleDb
- Public Class Form1
- Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:\CSDP\CP12\CP12 A\Midterm Don Antonio\MIDTERMDB.accdb"
- Public conn As New OleDbConnection
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- conn.ConnectionString = connstring
- If conn.State = ConnectionState.Closed Then
- conn.Open()
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim sqlquery As String = "SELECT * from TABLEMIDTERM1 where USERNAME=@field1 and PASSWORD=@field2"
- Dim sqlcommand As New OleDbCommand
- With sqlcommand
- .CommandText = sqlquery
- .Connection = conn
- .Parameters.AddWithValue("@field1", TextBox1.Text)
- .Parameters.AddWithValue("@field2", TextBox2.Text)
- .ExecuteNonQuery()
- End With
- Dim SqlRdr As OleDbDataReader
- SqlRdr = sqlcommand.ExecuteReader
- If (SqlRdr.Read()) Then
- MsgBox("Welcome to Black Mesa!")
- Else
- MsgBox("Try Again!")
- End If
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- TextBox1.Clear()
- TextBox2.Clear()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement