WaAh!
My form was working fine earlier but later it displays Invalid Operation Exception was unhandled. I don't know what's wrong with my form every time I load it.I checked its codes but I find what's wrong with it.
If I'm going to remove Transaction.Cou rses.Show(False , txtSearch.Text) at line #2 of frmCourses it works fine. Of course I cannot filter the records : (
This is my sample codes clsCourses -
#Region " Variable Declarations..."
-
Private ModColor As Boolean
-
Private SQLString As String
-
Private i As Integer
-
Private adItem As ListViewItem
-
Private rsCourses As OleDbDataReader
-
Private cmdCourses As New OleDbCommand
-
#End Region
-
-
Public Sub Show(ByVal ShowAllList As Boolean, Optional ByVal Search As String = vbNullString)
-
Windows.Forms.Cursor.Current = Cursors.WaitCursor
-
If ShowAllList Then
-
SQLString = "Select * From Courses Order By Title ASC"
-
Else
-
SQLString = "Select * From Courses Where CourseID Like '%" & Search & _
-
"%' Or Title Like '%" & Search & "%' Or Description Like '%" & _
-
Search & "%' Order By Title ASC"
-
End If
-
-
Call SetConnection()
-
cmdCourses = New OleDbCommand(SQLString, dbConnection)
-
cmdCourses.CommandType = CommandType.Text
-
rsCourses = cmdCourses.ExecuteReader
-
-
frmCourses.lvwCourses.Items.Clear()
-
While rsCourses.Read
-
adItem = frmCourses.lvwCourses.Items.Add(rsCourses(0), 0) 'Course ID
-
adItem.SubItems.Add(rsCourses(1)) 'Title
-
adItem.SubItems.Add(rsCourses(2)) 'Description
-
End While
-
-
frmCourses.lblTotalRecords.Text = "Total Records: " & frmCourses.lvwCourses.Items.Count
-
-
If frmCourses.lvwCourses.Items.Count > 0 Then
-
frmCourses.lblShowStatus.Visible = False
-
Else
-
frmCourses.lblShowStatus.Visible = True
-
End If
-
-
For i = 0 To frmCourses.lvwCourses.Items.Count - 1
-
If ModColor = True Then
-
frmCourses.lvwCourses.Items(i).BackColor = Color.AliceBlue
-
ModColor = False
-
Else
-
frmCourses.lvwCourses.Items(i).BackColor = Color.White
-
ModColor = True
-
End If
-
Next
-
-
rsCourses.Close()
-
Call CloseConnection()
-
Windows.Forms.Cursor.Current = Cursors.Default
-
End Sub
frmCourses - Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
-
Transaction.Courses.Show(False, txtSearch.Text)
-
End Sub
-
-
Private Sub frmCourses_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Main.SetChildForm(frmMain, Me)
-
Transaction.Courses.Show(True)
-
End Sub
-
Rey Sean
5 3192
An integer, eg an id, can't be like another incl in an sql statement. Suggest using try catch blocks and/ or other error handling. HTH.
An integer, eg an id, can't be like another incl in an sql statement. Suggest using try catch blocks and/ or other error handling. HTH.
Hi
Thanks for your reply : )
I've used try and catch blocks as what you've said but still it gives me an error result, An error occurred creating the form. See Exception.Inner Exception for details. The error is: The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor refer to the form using 'Me.'
BTW, what do you mean by incl?
Rey Sean
Plater 7,872
Recognized Expert Expert
Well what I saw turned out to be exactly what the error was giving you. So I think I am right on this.
In your form_load function (which gets called everytime it's shown) you are trying to SHOW it again. Which would lead to infinite recurrsion.
Remove the unneeded .Show() call like you said to make it work.
It shouldn't be there anyway.
Well what I saw turned out to be exactly what the error was giving you. So I think I am right on this.
In your form_load function (which gets called everytime it's shown) you are trying to SHOW it again. Which would lead to infinite recurrsion.
Remove the unneeded .Show() call like you said to make it work.
It shouldn't be there anyway.
If that is the reason I think I should create another method for clsCourses for filtering the records. But I don't think that is the best idea because I am going to create another method again with almost the same as with the showing of records the only difference between them is their sql statement. Can you give me another idea how to handle this?
Rey Sean
Plater 7,872
Recognized Expert Expert
Well lets start off with why are you continuing to make another instance of your class? (Or at least calling Show many times)
If you want to hide the form and then unhide it, use the Visible property?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ron |
last post by:
I am trying to run asp.net pages. The server is accessed
via http://sitename/username
I have verified it is using port 80 and aspx extensions
are configured. But when I run and asp.net page I get the
following error:
Invalid file name for monitoring: 'E:\'. File names for
monitoring must have absolute paths, and no wildcards.
Description: An unhandled exception occurred during the
|
by: Glenn A. Harlan |
last post by:
Why am I receiving the below error when calling - Path.GetTempFileName()
The directory name is invalid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.IO.IOException: The directory name is invalid.
|
by: simpsoro |
last post by:
I am trying to run asp.net pages. The server is accessed by students
via http://sitename/username
I have verified it is using port 80 and aspx extensions
are configured. But when I run and asp.net page I get the
following error:
Invalid file name for monitoring: 'E:\'. File names for
monitoring must have absolute paths, and no wildcards.
Description: An unhandled exception occurred during the
|
by: King Kong |
last post by:
we are facing this kind of error when we double click the infragistic web
grid
please help me on this
Regards
Moid Iqbal
Server Error in '/NetworkAccess' Application.
----------------------------------------------------------------------------
----
|
by: Ron Simpson |
last post by:
I am trying to run asp.net pages. The server is accessed
via http://sitename/username
I have verified it is using port 80 and aspx extensions
are configured. But when I run and asp.net page I get the
following error:
Invalid file name for monitoring: 'E:\'. File names for
monitoring must have absolute paths, and no wildcards.
Description: An unhandled exception occurred during the
| |
by: lds |
last post by:
I am getting the following error:
The "SendUsing" configuration value is invalid.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The
"SendUsing" configuration value is invalid.
|
by: VB Programmer |
last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When
I precomile it to my web deployment project and then copy the debug files to
my web server I get this problem when trying to login (obviously it's using
ASPNETDB.mdf). Any ideas?
Server Error in '/' Application.
--------------------------------------------------------------------------------
|
by: Ron |
last post by:
Hi,
I had a stored procedure on SQL 2000 server to run calculation with
large amount of data. When I called this stored procedure via
System.Data.SqlClient.SqlCommand on production, i got error as: (i
tried to run the stored procedure on query analyzer, and it works well)
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding.
Description: An unhandled exception occurred...
|
by: Jim Underwood |
last post by:
I am having a problem with my web page timng out while retrieving a long
runnign report (90-120 seconds. I have tried modifying several settings in
various places and cannot get it to run for more than 90 seconds.
I am running VS.Net and the app is ASP.Net, written using VB.Net. The app
calls an asp.Net web service to retrieve the report. Both the web site and
the web service are running locally on my PC.
I have tried modifying the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |