Why do I get SystemOverFlowException

scheidel21

Member
Joined
May 17, 2007
Messages
8
Location
Connecticut, USA
Programming Experience
5-10
I am designing a VB.NET front end to an MS Access Database, I have a form which is used for employee information, the information from the employees Table are in individual controls on the form, then there are 5 datagrids that display Other table information specifically for that employee via a relationship. I have attached a picture of the form design, Anyways within this database there are several tables that hold lookup information and so I have replaced some text box controls with comboboxes that are bound to their selectedText value and bind to the databases appropriate field, but the list is from another table of values, in order to do this I have two datasets the Employee information dataset and the Admin dataset the admin dataset contains all the tables that have lookup values.

Well when all put together if I attempt to run the form from my MDI interface via a button on another child form I get

System.StackOverFlowException in System.windows.forms.dll

If I set it as startup form it loads and I can choose one of the comboboxes and see the list, if I attempt to do anything else after that it throws

System.StackOverFlowException in system.windows.forms.dll

If I try to change the databinding record position i.e. move through records I get

System.StackOverFlowException in system.windows.forms.dll

Basically you see the problem here, I am designing on a laptop sporting Turion X2 1.8ghz 2GB RAM, and 100 GIG HD, I don't think it could be a hardware limitation. Any help would be appreciated.

VB.NET:
Dim odbAISConnection As New OleDb.OleDbConnection(_
"Provider=Microsoft.Jet.OLEDB.4.0.;" & "Data Source=" & Application.StartupPath _
& "\Data\Employees.edb;User Id=Admin;Password=")
    Dim odbaEmployees As New OleDb.OleDbDataAdapter
    Dim odbaCerts As New OleDb.OleDbDataAdapter
    Dim odbaAddresses As New OleDb.OleDbDataAdapter
    Dim odbaPhone As New OleDb.OleDbDataAdapter
    Dim odbaEC As New OleDb.OleDbDataAdapter
    Dim odbaMedctrl As New OleDb.OleDbDataAdapter

    Dim odbsEmployees As New OleDb.OleDbCommand(_
"Select Employees.* FROM Employees ORDER BY txtLastName, txtFirstName, txtMiddleInitial")
    Dim odbsCerts As New OleDb.OleDbCommand("Select Certs.* FROM Certs")
    Dim odbsAddresses As New OleDb.OleDbCommand("Select Addresses.* FROM Addresses")
    Dim odbsPhone As New OleDb.OleDbCommand("Select PhoneNumbers.* FROM PhoneNumbers")
    Dim odbsEC As New OleDb.OleDbCommand("Select EmergencyContacts.* FROM EmergencyContacts")
    Dim odbsMedctrl As New OleDb.OleDbCommand("Select Medctrl.* FROM Medctrl")

    Dim odbcEmployees As New OleDb.OleDbCommandBuilder(odbaEmployees)
    Dim odbcCerts As New OleDb.OleDbCommandBuilder(odbaCerts)
    Dim odbcAddresses As New OleDb.OleDbCommandBuilder(odbaAddresses)
    Dim odbcPhone As New OleDb.OleDbCommandBuilder(odbaPhone)
    Dim odbcEC As New OleDb.OleDbCommandBuilder(odbaEC)
    Dim odbcMedctrl As New OleDb.OleDbCommandBuilder(odbaMedctrl)

    Dim odbaTrucks As New OleDb.OleDbDataAdapter
    Dim odbaCertList As New OleDb.OleDbDataAdapter
    Dim odbaPhoneTypes As New OleDb.OleDbDataAdapter
    Dim odbaStatusList As New OleDb.OleDbDataAdapter
    Dim odbaShiftType As New OleDb.OleDbDataAdapter
    Dim odbaTrain As New OleDb.OleDbDataAdapter
    Dim odbaOffense As New OleDb.OleDbDataAdapter
    Dim odbaLevel As New OleDb.OleDbDataAdapter
    Dim odbaLocations As New OleDb.OleDbDataAdapter
    Dim odbaWeeks As New OleDb.OleDbDataAdapter
    Dim odbaClass As New OleDb.OleDbDataAdapter
    Dim odbaHospitals As New OleDb.OleDbDataAdapter
    Dim odbaDays As New OleDb.OleDbDataAdapter
    Dim odbaDisciplineActions As New OleDb.OleDbDataAdapter
    Dim odbaZips As New OleDb.OleDbDataAdapter

    Dim odbsTrucks As New OleDb.OleDbCommand("Select Trucks.* FROM Trucks")
    Dim odbsCertList As New OleDb.OleDbCommand("Select CertificationList.* FROM CertificationList")
    Dim odbsPhoneTypes As New OleDb.OleDbCommand("Select PhoneTypeList.* FROM PhoneTypeList")
    Dim odbsStatusList As New OleDb.OleDbCommand("Select StatusList.* FROM StatusList")
    Dim odbsShiftType As New OleDb.OleDbCommand("Select ShiftTypeList.* FROM ShiftTypeList")
    Dim odbsTrain As New OleDb.OleDbCommand("Select TrainingTypeList.* FROM TrainingTypeList")
    Dim odbsOffense As New OleDb.OleDbCommand("Select OffenseList.* FROM OffenseList")
    Dim odbsLevel As New OleDb.OleDbCommand("Select LevelList.* FROM LevelList")
    Dim odbsLocations As New OleDb.OleDbCommand("Select LocationList.* FROM LocationList")
    Dim odbsWeeks As New OleDb.OleDbCommand("Select WeeksList.* FROM WeeksList")
    Dim odbsClass As New OleDb.OleDbCommand("Select ClassList.* FROM ClassList")
    Dim odbsHospitals As New OleDb.OleDbCommand("Select HospitalList.* FROM HospitalList")
    Dim odbsDays As New OleDb.OleDbCommand("Select DayofWeek.* FROM DayofWeek")
    Dim odbsDisciplineActions As New OleDb.OleDbCommand("Select ActionsList.* FROM ActionsList")
    Dim odbsZips As New OleDb.OleDbCommand("Select ZipCodes.* FROM ZipCodes ORDER BY State_Abbreviation")

    Dim odbcTrucks As New OleDb.OleDbCommandBuilder(odbaTrucks)
    Dim odbcCertList As New OleDb.OleDbCommandBuilder(odbaCertList)
    Dim odbcPhoneTypes As New OleDb.OleDbCommandBuilder(odbaPhonetypes)
    Dim odbcStatusList As New OleDb.OleDbCommandBuilder(odbaStatusList)
    Dim odbcShiftType As New OleDb.OleDbCommandBuilder(odbaShiftType)
    Dim odbcTrain As New OleDb.OleDbCommandBuilder(odbaTrain)
    Dim odbcOffense As New OleDb.OleDbCommandBuilder(odbaOffense)
    Dim odbcLevel As New OleDb.OleDbCommandBuilder(odbaLevel)
    Dim odbcLocations As New OleDb.OleDbCommandBuilder(odbaLocations)
    Dim odbcWeeks As New OleDb.OleDbCommandBuilder(odbaWeeks)
    Dim odbcClass As New OleDb.OleDbCommandBuilder(odbaClass)
    Dim odbcHospitals As New OleDb.OleDbCommandBuilder(odbaHospitals)
    Dim odbcDays As New OleDb.OleDbCommandBuilder(odbaDays)
    Dim odbcDisciplineActions As New OleDb.OleDbCommandBuilder(odbaDisciplineActions)
    Dim odbcZips As New OleDb.OleDbCommandBuilder(odbaZips)

    Dim dsAdmin As New Data.DataSet

    Dim dsEmployees As New Data.DataSet

    Public Sub LoadCombo()
        Me.cmbSelectEmp.Items.Clear()
        Dim i As Int16 = 0
        Dim Name As String
        For i = 0 To Me.dsEmployees.Tables("Employees").Rows.Count - 1
            Name = Me.dsEmployees.Tables("Employees").Rows(i).Item(0) _
& " -- " _
& Me.dsEmployees.Tables("Employees").Rows(i).Item(1) _
& ", " _
& Me.dsEmployees.Tables("Employees").Rows(i).Item(2) _
& " " _
& Me.dsEmployees.Tables("Employees").Rows(i).Item(3)
            Me.cmbSelectEmp.Items.Add(Name)
        Next
        Me.cmbSelectEmp.SelectedIndex = 0
    End Sub


    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Try
            'Clear out the current edits
            Me.BindingContext(dsEmployees, "Employees").EndCurrentEdit()
            Me.BindingContext(dsEmployees, "Employees").AddNew()
        Catch eEndEdit As System.Exception
            System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
        End Try


    End Sub

    Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNavFirst.Click
        Me.BindingContext(dsEmployees, "Employees").Position = 0


    End Sub
    Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
        Me.BindingContext(dsEmployees, "Employees").Position = (Me.dsEmployees.Tables("Employees").Rows.Count - 1)


    End Sub
    Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNavPrev.Click
        Me.BindingContext(dsEmployees, "Employees").Position = (Me.BindingContext(dsEmployees, "Employees").Position - 1)


    End Sub
    Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNavNext.Click
        Me.BindingContext(dsEmployees, "Employees").Position = (Me.BindingContext(dsEmployees, "Employees").Position + 1)


    End Sub
    

    Private Sub frmEmployeeAdmin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Me.editdtAdjDOH.Text.Format

        odbaEmployees.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaEmployees.SelectCommand = odbsEmployees
        odbaEmployees.SelectCommand.Connection = odbAISConnection

        odbaCerts.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaCerts.SelectCommand = odbsCerts
        odbaCerts.SelectCommand.Connection = odbAISConnection

        odbaAddresses.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaAddresses.SelectCommand = odbsAddresses
        odbaAddresses.SelectCommand.Connection = odbAISConnection

        odbaPhone.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaPhone.SelectCommand = odbsPhone
        odbaPhone.SelectCommand.Connection = odbAISConnection

        odbaEC.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaEC.SelectCommand = odbsEC
        odbaEC.SelectCommand.Connection = odbAISConnection

        odbaMedctrl.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaMedctrl.SelectCommand = odbsEC
        odbaMedctrl.SelectCommand.Connection = odbAISConnection

        Try
            dsEmployees.ReadXmlSchema(Application.StartupPath & "\Data\EmployeeData.xsd")
        Catch ex As Exception
            MessageBox.Show("File Missing Try again", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
        End Try
        Try
            odbaEmployees.Fill(dsEmployees, "Employees")
            odbaCerts.Fill(dsEmployees, "Certs")
            odbaAddresses.Fill(dsEmployees, "Addresses")
            odbaPhone.Fill(dsEmployees, "PhoneNumbers")
            odbaEC.Fill(dsEmployees, "EmergencyContacts")
            odbaMedctrl.Fill(dsEmployees, "Medctrl")
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
        End Try

        Me.odbAISConnection.Open()

        odbaTrucks.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaTrucks.SelectCommand = odbsTrucks
        odbaTrucks.SelectCommand.Connection = odbAISConnection

        odbaCertList.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaCertList.SelectCommand = odbsCertList
        odbaCertList.SelectCommand.Connection = odbAISConnection

        odbaPhoneTypes.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaPhoneTypes.SelectCommand = odbsPhoneTypes
        odbaPhoneTypes.SelectCommand.Connection = odbAISConnection

        odbaStatusList.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaStatusList.SelectCommand = odbsStatusList
        odbaStatusList.SelectCommand.Connection = odbAISConnection

        odbaShiftType.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaShiftType.SelectCommand = odbsShiftType
        odbaShiftType.SelectCommand.Connection = odbAISConnection

        odbaTrain.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaTrain.SelectCommand = odbsTrain
        odbaTrain.SelectCommand.Connection = odbAISConnection

        odbaOffense.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaOffense.SelectCommand = odbsOffense
        odbaOffense.SelectCommand.Connection = odbAISConnection

        odbaLevel.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaLevel.SelectCommand = odbsLevel
        odbaLevel.SelectCommand.Connection = odbAISConnection

        odbaLocations.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaLocations.SelectCommand = odbsLocations
        odbaLocations.SelectCommand.Connection = odbAISConnection

        odbaWeeks.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaWeeks.SelectCommand = odbsWeeks
        odbaWeeks.SelectCommand.Connection = odbAISConnection

        odbaClass.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaClass.SelectCommand = odbsClass
        odbaClass.SelectCommand.Connection = odbAISConnection

        odbaHospitals.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaHospitals.SelectCommand = odbsHospitals
        odbaHospitals.SelectCommand.Connection = odbAISConnection

        odbaDays.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaDays.SelectCommand = odbsDays
        odbaDays.SelectCommand.Connection = odbAISConnection

        odbaDisciplineActions.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaDisciplineActions.SelectCommand = odbsDisciplineActions
        odbaDisciplineActions.SelectCommand.Connection = odbAISConnection

        odbaZips.MissingSchemaAction = MissingSchemaAction.AddWithKey
        odbaZips.SelectCommand = odbsZips
        odbaZips.SelectCommand.Connection = odbAISConnection

        Try
            dsAdmin.ReadXmlSchema(Application.StartupPath & "\Data\Admin.xsd")
        Catch ex As Exception
            MessageBox.Show("File Missing Try again", "Missing", MessageBoxButtons.OK, MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
        End Try
        Try
            odbaTrucks.Fill(dsAdmin, "Trucks")
            odbaCertList.Fill(dsAdmin, "CertificationList")
            odbaPhoneTypes.Fill(dsAdmin, "PhoneTypeList")
            odbaStatusList.Fill(dsAdmin, "StatusList")
            odbaShiftType.Fill(dsAdmin, "ShiftTypeList")
            odbaTrain.Fill(dsAdmin, "TrainingTypeList")
            odbaOffense.Fill(dsAdmin, "OffenseList")
            odbaLevel.Fill(dsAdmin, "LevelList")
            odbaLocations.Fill(dsAdmin, "LocationList")
            odbaWeeks.Fill(dsAdmin, "WeeksList")
            odbaClass.Fill(dsAdmin, "ClassList")
            odbaHospitals.Fill(dsAdmin, "HospitalList")
            odbaDays.Fill(dsAdmin, "DayofWeek")
            odbaDisciplineActions.Fill(dsAdmin, "ActionsList")
            odbaZips.Fill(dsAdmin, "ZipCodes")
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
        End Try
        Me.odbAISConnection.Close()

        LoadCombo()


        Dim i As Int32 = 0
        Dim Name As String = Nothing
        For i = 0 To Me.dsAdmin.Tables("ZipCodes").Rows.Count - 1
            If Name = Me.dsAdmin.Tables("ZipCodes").Rows(i).Item(2) Then
            Else
                Name = Me.dsAdmin.Tables("ZipCodes").Rows(i).Item(2)
                Me.cmbtxtST.Items.Add(Name)
            End If
        Next

        i = 0
        For i = 0 To Me.dsAdmin.Tables("ClassList").Rows.Count - 1
            Name = Me.dsAdmin.Tables("ClassList").Rows(i).Item(1)
            Me.cmbstrClass.Items.Add(Name)
        Next

        i = 0
        For i = 0 To Me.dsAdmin.Tables("StatusList").Rows.Count - 1
            Name = Me.dsAdmin.Tables("StatusList").Rows(i).Item(0)
            Me.cmbstrStatus.Items.Add(Name)
        Next

        'me.cmbtxtST.SelectedText
        Me.editEmpID.DataBindings.Add("Text", dsEmployees, "Employees.EmpID")
        Me.edittxtLastName.DataBindings.Add("Text", dsEmployees, "Employees.txtLastName")
        Me.edittxtFirstName.DataBindings.Add("Text", dsEmployees, "Employees.txtFirstName")
        Me.edittxtMiddleInitial.DataBindings.Add("Text", dsEmployees, "Employees.txtMiddleInitial")
        Me.editdtDOB.DataBindings.Add("Text", dsEmployees, "Employees.dtDOB")
        Me.edittxtSS.DataBindings.Add("Text", dsEmployees, "Employees.txtSS")
        Me.editdtDOH.DataBindings.Add("Text", dsEmployees, "Employees.dtDOH")
        Me.cmbstrClass.DataBindings.Add("SelectedText", dsEmployees, "Employees.strClassification")
        'Me.editstrClassification.DataBindings.Add("Text", dsEmployees, "Employees.strClassification")
        Me.cmbstrStatus.DataBindings.Add("SelectedText", dsEmployees, "Employees.strStatus")
        'Me.editstrStatus.DataBindings.Add("Text", dsEmployees, "Employees.strStatus")
        Me.editdtAdjDOH.DataBindings.Add("Text", dsEmployees, "Employees.dtAdjDOH")
        Me.editdtPDE.DataBindings.Add("Text", dsEmployees, "Employees.dtPDE")
        Me.edittxtDLN.DataBindings.Add("Text", dsEmployees, "Employees.txtDLN")
        Me.cmbtxtST.DataBindings.Add("SelectedText", dsEmployees, "Employees.txtDLST")
        'Me.edittxtDLST.DataBindings.Add("Text", dsEmployees, "Employees.txtDLST")
        Me.editdtDLExp.DataBindings.Add("Text", dsEmployees, "Employees.dtDLExp")
        Me.edittxtDLRes.DataBindings.Add("Text", dsEmployees, "Employees.txtDLRes")
        Me.edittxtDLEnd.DataBindings.Add("Text", dsEmployees, "Employees.txtDLEnd")
        Me.editbNU.DataBindings.Add("Checked", dsEmployees, "Employees.bNU")
        Me.editbHBVDec.DataBindings.Add("Checked", dsEmployees, "Employees.bHBVDec")
        Me.editdtHBVDecD.DataBindings.Add("Text", dsEmployees, "Employees.dtHBVDecD")
        Me.editdtHBV.DataBindings.Add("Text", dsEmployees, "Employees.dtHBV")
        Me.editdtHBV1.DataBindings.Add("Text", dsEmployees, "Employees.dtHBV1")
        Me.editdtHBV2.DataBindings.Add("Text", dsEmployees, "Employees.dtHBV2")
        Me.editdtHBVT.DataBindings.Add("Text", dsEmployees, "Employees.dtHBVT")
        Me.editdtPPD.DataBindings.Add("Text", dsEmployees, "Employees.dtPPD")
        Me.editdtOSHA.DataBindings.Add("Text", dsEmployees, "Employees.dtOSHA")
        Me.editdtHaz.DataBindings.Add("Text", dsEmployees, "Employees.dtHaz")
        Me.editComments.DataBindings.Add("Text", dsEmployees, "Employees.Comments")

        'Me.dgCerts.DataSource = dsEmployees
        'Me.dgCerts.DataMember = "Employees.EmployeesCerts"

        'Me.dgAddress.DataSource = dsEmployees
        'Me.dgAddress.DataMember = "Employees.EmployeesAddresses"

        'Me.dgPhones.DataSource = dsEmployees
        'Me.dgPhones.DataMember = "Employees.EmployeesPhoneNumbers"

        'Me.dgEC.DataSource = dsEmployees
        'Me.dgEC.DataMember = "Employees.EmployeesEmergencyContacts"

        'Me.dgMedctrl.DataSource = dsEmployees
        'Me.dgMedctrl.DataMember = "Employees.EmployeesMedctrl"


    End Sub

Edit to change the exception above made a mistake.
 

Attachments

  • EmployeeForm.JPG
    EmployeeForm.JPG
    168.6 KB · Views: 40
  • Dissassembly.JPG
    Dissassembly.JPG
    23.8 KB · Views: 38
StackOverflows occur when a method call sequence goes too deep.

Here is an example using recursion to cause a StackOverflow:

VB.NET:
  Public Sub CrashMe()
    CrashMe()
  End Sub

Because the stack is quite big.. more than a thousand calls, it is unlikely that you could achieve this without runaway recursion.. i.e. there isnt anywhere in the framework where a sub calls another sub that calls another sub that...... 1000 subs later is still calling another sub..

All i can suggest is that you go to the debug menu and in the Exceptions entry, put a tick next to "Thrown" for all CLR exceptions. As soon as the stack overflows, the program will halt, then you should show the Call Stack (Debug window)

It will repeat somewhere.. examine the last sub of the repeating block and see where it calls the first sub of the repeating block

VB.NET:
Call stack:
1
 2
  3
   4
    2
     3
      4
       2
        3
         4
          2
           3
            4
4 calls 2. Fix it
 
Well where am I going too deep in my code? It's pretty straightforward, except for the declaration of all the dataset variable and Select querys etc.... which are needed for this application ......there isn't anything too bad, just four for...next loops that load once on form load
 
pps; youre using ,NET 2 - and it looks like youre making your Data Access very much hard work for yourself. Have a read of the DW2 link in my signature instead, section on creating a simple app
 
Well where am I going too deep in my code? It's pretty straightforward, except for the declaration of all the dataset variable and Select querys etc.... which are needed for this application ......there isn't anything too bad, just four for...next loops that load once on form load

I havent got a clue, and burning my eyes out looking at your massive block of code which may or may not be causing the error isnt something I'm going to do. You have to use your own debugger in a smart way to catch this one... I edited my post about a minute before you posted your response, so you might have missed the edits. Have a read of them and see if they help

Your code may seem straight forward to you.. But it's Old Way. I use New Way, which redefines straight-forward to about 1% of the lines you've put there. DW2 explains New Way. For user testimonials, I guess pachjo's recent words were the ones which made me laugh most:

pachjo in [url said:
http://www.vbdotnetforums.com/showpost.php?p=59579&postcount=7][/url]
Hi well cjard I would say it is almost, well it is, down to you that I have restarted my application with the same interface but the engine, guts or whatever you want to call it is now taking shape in amuch more streamlined and easier way to code and understand.

This of course being down to the use of datasets, tableadapters and bindingsources.

The more I do it this way and see how much 'dross' I remove and replace with far fewer lines the more I am insensed with the SAMS books for showing me the crap way.
 
Well It was my mistake I am using the .net 1.1 Sp1 framework not 2.0 first off and secondly I read the DW2 link in your sig as you suggested I know I could create the objects that way, but I actually prefer codingthings that are noy user interface, i.e. using the designer to create buttons, text boxes etc... but I find that I have a harder time dynamically doing this with data controls etc... if I use the designer to create them, for one I like to dynamically create the connection dtring to the datasource such as using Application.startupPath & "\somedatabase" when I first started doing this I had a hell of a time and couldn't get that to change with designer created data objects. So what I do is declare say a Database connection and dataset then create a dataset based on an XML schema directly from the backend database, and proceed to fill the dataset from said dataconnection. In short I feel I get mcuh more control over it this way.

I really don't think this error is in my code though I have stepped through the code, set breakpoints, checked variables, even created a new project and rewrote the code and created the GUI from scratch and I get the error again. I have streamlined it taken out all commented code from the original and placed everything in it's own sub.

So now I have the windows generated code for the form then the declarations (Database Connection Variable and dataset variable declaration) proceeded by a loaddata sub which sets the dataset schema to the xml file, then proceeds to ensure that all data is added properly with the missing schema action, then creates the dataadapters and select queries, finally filling the dataset. Then next is the load EmployeeCombo box which takes the empID field, EmpLastName, Emp FirstName, andempMiddleName fields which creating a string which it adds to the select employee combobox. Then a loadlookupcombos which adds the data from the lookup tables into the collection in the appropriate combo boxes. Finally a databinding sub which proceeeds to bind each control to the appropriate field in the table employees within mydataset. I then call the on load function of the form which in turn calls these four previous subs. Finally I finish off with the selectedindex_changes method of the employees combobox to change the bindingcontext position of the datacontrols when a different person is selected.

Like I said I rewrote it from scratch I will attach a zip file of the rewrite it has everything you need to try it and no need to change variables or anything my dynamic connection string wil take care of that. Thank you for the advice though.

PS the overloadexception is the same exact one as the original with the same triggers (Well I don't know about the crash when called from another form) and in the same exact place in the dissassembly. I only wonder if the zip codes table with all that data is overloading the system, but it runs the for loop with no problem and once the form is loaded the sub doesn't get run again
 

Attachments

  • EDB2.zip
    830.8 KB · Views: 83
Well It was my mistake I am using the .net 1.1 Sp1 framework not 2.0
It says 2.0 under your name. I hope you can forgive me for making the assumption that you were using 2.0 :)


if I use the designer to create them, for one I like to dynamically create the connection dtring to the datasource such as using Application.startupPath & "\somedatabase" when I first started doing this I had a hell of a time and couldn't get that to change with designer created data objects.
I can tell you an easy way to do that.. but its usually not needed in cases where the DB is in the same directory as the exe


PS the overloadexception is the same exact one as the original with the same triggers (Well I don't know about the crash when called from another form) and in the same exact place in the dissassembly. I only wonder if the zip codes table with all that data is overloading the system, but it runs the for loop with no problem and once the form is loaded the sub doesn't get run again

See the original advice re looking at the Call Stack
 
I've downlaoded, compiled and run your app, and I've messed with everything i could click on. I cannot reproduce your StackOverflow. The only thing I got was FormatException from textboxes that are for dates. Use DateTimePicker for dates. If you need them to be null, google for Nullable DateTimePicker
 
Actually I found where the problem was, and I needed to bond the table fields that were in the comboboxes to the text property not SelectedText Property. I wonder if you running a newer version of VB might make a differnce in the compile. oh well thank you for trying. As I said it was my mistake stating I was using 2.0. As for the daate time picker I just want
them to enter a date in mm/dd/yyyy format or the shortdate because the data might me ages different and it's easier to type than to scroll through
calender pages to select a date. Anywho I just have to format the text boxes appropriatly.
 
them to enter a date in mm/dd/yyyy format or the shortdate because the data might me ages different and it's easier to type than to scroll through
calender pages to select a date. Anywho I just have to format the text boxes appropriatly.

Er.. you can type into a DTP too.. And you can set its format.. Also set the ShowUpDown to true and you wont see the calendar dropdown button.
 

Latest posts

Back
Top