Having a problem setting up a login form for my project,
here's the code:
Imports System
Imports System.Data.SqlClient
Public Class Login
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim rd As SqlDataReader
Private Sub dataopen()
con.ConnectionString = "Server=IGNITER-PC\OBEXPRESS;Database=EMS;User ID=sa;Password=au"
con.Open()
End Sub
Private Sub EmsStickyButton1_Click(sender As Object, e As EventArgs) Handles EmsStickyButton1.Click
dataopen()
cmd.Connection = con
cmd.CommandText = "Select User_Name, userpass from Borrower where sername='" & EmsTextBox1.Text & "' AND password = '" & EmsTextBox2.Text & "'"
rd = cmd.ExecuteReader
If rd.HasRows Then
MsgBox("SUCCESS")
Else
MsgBox("wrong")
End If
End Sub
End Class
It just throwing me :
A first chance exception of type 'System.NullReferenceException' occurred in EMS.exe
An unhandled exception of type 'System.NullReferenceException' occurred in EMS.exe
Additional information: Object reference not set to an instance of an object.
Please help me thanks!