I'm having some issues with this code:
Imports System.Data.SqlClient
Public Class loginForm
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'--Connection string to POS database
Dim loginFormConnection As New SqlConnection("SERVER = localhost\SQLExpress; DATABASE = POS; INTEGRATED SECURITY = true;")
'--Check to see if Windows Point of Sale is being ran for the first time
Try
'--SQL command to check firstRun table in the database
Dim firstRunCommand As New SqlCommand("SELECT * FROM firstRun")
firstRunCommand.Connection = loginFormConnection
'--Open the database connection
loginFormConnection.Open()
'--Datareader for firstRunCommand
Dim firstRunDataReader As SqlDataReader = firstRunCommand.ExecuteReader
'--Close the database Connection
loginFormConnection.Close()
'--Change the form based on results from reader
If (firstRunDataReader.HasRows = True) Then
firstRunButton.Hide()
Else
firstRunButton.Show()
End If
Catch ex As SqlException
MsgBox("Cannot connect to Windows Point of Sale Database.", MsgBoxStyle.Information, "Error 0001")
End Try
End Sub
End Class
Every time I try to debug the application I get the following error:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
If any one can give me some guidance I would be grateful.
Thank You