Start New Discussion within our Software Development Community

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
            '--SQL command to check firstRun table in the database
            Dim firstRunCommand As New SqlCommand("SELECT * FROM firstRun")
            firstRunCommand.Connection = loginFormConnection
            '--Open the database connection
            '--Datareader for firstRunCommand
            Dim firstRunDataReader As SqlDataReader = firstRunCommand.ExecuteReader
            '--Close the database Connection

            '--Change the form based on results from reader
            If (firstRunDataReader.HasRows = True) Then
            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

Imports System.Data.OleDb
Module Module1

Public conn As New OleDbConnection

Public Sub open()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=reservation.mdb"

End Sub

End Module

This article has been dead for over six months. Start a new discussion instead.