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
|