Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2008, 11:39 PM
Authorized User
 
Join Date: Jan 2008
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default invalidoperationexception?

Hi

i need help in winform application using VS 2005
i got this warning, what does it mean?
please help... thanks in advance..

"A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll"

Private Sub Form1_Load
    Try
       Call InsertDAtagridProduct()
    Catch ex As Exception

        End Try
End Sub

Private Sub InsertDAtagridProduct()
        Dim myBook As New clsBook
        Dim strFilter As String
        Try
            If txtFilter.Text = "" Then
                strFilter = ""
            Else
                strFilter = Trim(txtFilter.Text)
            End If
 '================================================= ========================
            If myBook.GetBookData(strFilter) = True Then
                dgproduct.DataSource = ds
                dgproduct.DataMember = "Product"
        conn.Close()
            Else
                MessageBox.Show("No Record Found")
            End If

        Catch ex As Exception

        End Try
End Sub

================================
Imports System.Data.SqlClient

Public Class clsBook
    Public Function GetBookData(Optional ByVal pi_strFilter As String = "") As Boolean
        Try
            conn.Open() 'after execute this line, i can't go into below line as catch the warning like above and will get ("No Record Found")
            Dim strcmd As String, strW As String
            strW = ""
            If pi_strFilter <> "" Then
                strW = " ProductName like '%" & pi_strFilter & "%'"
            End If
            strcmd = "SELECT ProductID, ProductName,ProductTypeName,Description, " _
                        & "Stock FROM tblProduct a LEFT JOIN tblProductType b " _
                        & "ON a.ProductType = b.ProductTypeID" _
                        & IIf(strW = "", "", " WHERE " & strW)

            da = New SqlDataAdapter(strcmd, conn)
            ds = New DataSet("Product")
            da.Fill(ds, "Product")
            GetBookData = True
            conn.Close()
        Catch ex As Exception
            conn.Close()
            GetBookData = False
        End Try

    End Function
End Class

=============================
Imports System.Data.SqlClient

Module modConnection
    Public conn As New SqlConnection("Data Source=(local);Initial Catalog=TESTING;Integrated Security=True")
    Public dr As SqlDataReader
    Public da As New SqlDataAdapter
    Public ds As New DataSet
    Public cmd As New SqlCommand
End Module






Similar Threads
Thread Thread Starter Forum Replies Last Post
system.InvalidOperationException furjaw Visual Basic 2005 Basics 0 May 27th, 2006 12:44 AM
System.InvalidOperationException: connection dead aleahy General .NET 0 January 28th, 2005 07:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.