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

Recommended Answers

All 3 Replies

I solved my issue.

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

Be sure to close the thread if you have solved your issue.

Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.