We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,983 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Invalid Operation Exception

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

3
Contributors
3
Replies
6 Months
Discussion Span
1 Year Ago
Last Updated
4
Views
AaronDickey
Newbie Poster
5 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I solved my issue.

AaronDickey
Newbie Poster
5 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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"
conn.Open()


End Sub

End Module

tintin_14
Newbie Poster
1 post since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

Thank you.

Begginnerdev
Practically a Posting Shark
862 posts since Apr 2010
Reputation Points: 184
Solved Threads: 142
Skill Endorsements: 8

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0679 seconds using 2.68MB