[RESOLVED] [2005] Value Close() cannot be called while doing CreateHandle()
my database table creation works. now i have added a form with a progress bar when this is going through and now get an error when trying to close the form after the sql file has been successfully deleted.
Quote:
------------------------------Start Of Error------------------------------
Error Occurred On:
5/3/2008 12:31:40 PM
Data:
System.Collections.ListDictionaryInternal
Message:
Value Close() cannot be called while doing CreateHandle().
Stack Trace:
at System.Windows.Forms.Form.Close()
at BusinessStudio.frmSQLExecuteProgress.frmSQLExecuteProgress_Load(Object sender, EventArgs e) in D:\BusinessStudio\frmSQLExecuteProgress.vb:line 36
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
------------------------------ End Of Error ------------------------------
vb Code:
Public Class frmSQLExecuteProgress
Private Sub frmSQLExecuteProgress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'form layout
FormLayout(Me)
'specify the location of the dbu file
Dim strFileLocation As String = My.Application.Info.DirectoryPath & "\sql\sql.dbu"
With (My.Computer.FileSystem)
'lets see if the file exists
If System.IO.File.Exists(strFileLocation) Then
'read all the lines in the file
Dim arrDBULineCount() As String = IO.File.ReadAllLines(strFileLocation)
With prgDatabaseExecution
'set the minimum to 0%
.Minimum = 0
'set the maximum to 100%
.Maximum = 100
'give step the value of the number of lines in the dbu file
.Step = CInt(arrDBULineCount.Length.ToString)
'get the incremental by dividing the line count by 100
.Value = CInt(.Step / .Maximum)
'start the progress bar
.PerformStep()
If .Value = 100 Then
'now that the request has been completed, delete the file
IO.File.Delete(strFileLocation)
'close this screen
End If
End With
End If
End With
Me.Close()
End Sub
End Class
been working at this for a few hours and not sure what to do
Re: [2005] Value Close() cannot be called while doing CreateHandle()
You're calling Close on a form in its Load event handler. That's a no-no. Why would you do that? If you don't want the form open then why show it in the first place?
Re: [2005] Value Close() cannot be called while doing CreateHandle()
Quote:
Originally Posted by jmcilhinney
You're calling Close on a form in its Load event handler. That's a no-no. Why would you do that? If you don't want the form open then why show it in the first place?
oh my, i didnt even notice that! thanks jc
Re: [2005] Value Close() cannot be called while doing CreateHandle()
ok, added a button and using that to close the form. not thinking straight today it looks like :)