Question

How to fill DataGridView rows from DataSet when Form opens

Asked by: megnin

I have a DataGridView that updates a database.  Roger helped me with it and it works great.
When I close the app and open it back up the DataGridView rows are not populated again from the database.
All the information is in the database and in the DataSet, but is not being "filled" back into the DataGridView.

This code is in the Form1_Load event.  It looks like this should be doing the fill.  I don't understand why this doesn't fill the DataGridView rows on form load:

        'get the job titles for the applicants
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
        Next

Here's the fillInTitle sub:
    Private Sub fillInTitle(ByVal dgvr As DataGridViewRow)
        'check if there is a value in the third cell ...
        '... (index 2, which is the "Job" field ...
        '... in this row from the datagridview
        If TypeOf dgvr.Cells(2).Value Is DBNull Then
            'if not, then there is no Job Title
            dgvr.Cells(4).Value = ""
        Else
            'if there is, use it to get the Job Title
            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))
        End If
    End Sub

Thanks.
David

Below is the whole Form1.vb code for reference:
------------------------------------------------------------------------------------------------------------
Imports System.Data.SqlTypes
Imports System.Data
Imports System.Data.SqlClient
Imports System.Windows.Forms


'Look up some of the instructions on "refreshing" a DataGridView from the database...


Public Class Form1
    Private dtApplicants As New DataTable("Applicants")
    Private cmApplicants As CurrencyManager
    Private dtJobs As New DataTable("Jobs")
    Private dvjobs As New DataView
    Private WithEvents cmJobs As CurrencyManager

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SYEP2007DataSet.JobTitles' table. You can move, or remove it, as needed.
        Me.ApplicantsTableAdapter.Fill(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Fill(Me.SYEP2007DataSet.JobTitles)

        dtApplicants = Me.SYEP2007DataSet.Applicants
        dtJobs = Me.SYEP2007DataSet.JobTitles

        'filltables() 'equivalent to filling tables with ...
        '... a dataadapter or a tableadapter

        'get and display the count of applicant records
        Dim count As Integer = dtApplicants.Rows.Count
        txtTotalApplicants.Text = String.Format("{0} Applicants", count)

        'bind the applicants table to the datagridview
        ApplicantsDataGridView.DataSource = dtApplicants
        'set up the currencymanager - convenient for referring ...
        '... to the currently selected row in the applicants grid
        cmApplicants = CType(BindingContext(dtApplicants), CurrencyManager)

        'set up a dataview to filter the jobs table so it ...
        '... only shows those where some jobs remain available
        dvjobs.Table = dtJobs
        dvjobs.RowFilter = "txtWorksiteJobTitlePositionsNumber > 0"
        'bind the jobs table to the datagridview
        JobTitlesDataGridView.DataSource = dvjobs
        'set up the currency manager
        cmJobs = CType(BindingContext(dvjobs), CurrencyManager)

        'customise the grids - with a strongly typed dataset ...
        '... this could be done in the designer
        ApplicantsDataGridView.ReadOnly = True
        ApplicantsDataGridView.AllowUserToAddRows = False
        'hide the applicant ID
        ApplicantsDataGridView.Columns(0).Visible = False
        'hide the job ID ...
        ApplicantsDataGridView.Columns(2).Visible = False
        'hide the ProgramID column in Applicants DGV
        ApplicantsDataGridView.Columns(3).Visible = False
        '... but add an unbound column to show ...
        '... the job title matching that ID
        Dim TitleCol As New DataGridViewTextBoxColumn
        TitleCol.HeaderText = "Job Title"
        ApplicantsDataGridView.Columns.Add(TitleCol)

        Dim NumberofAdults As New DataGridViewTextBoxColumn
        NumberofAdults.HeaderText = "Adults"
        ApplicantsDataGridView.Columns.Add(NumberofAdults)

        JobTitlesDataGridView.ReadOnly = True
        JobTitlesDataGridView.AllowUserToAddRows = False
        JobTitlesDataGridView.Columns(0).Visible = False

        ApplicantsDataGridView.Columns(1).Width = 100

        'run the sub to fill the jobs numbers displays
        updateTotals()

        'get the job titles for the applicants
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
        Next
        TabControl1.SelectedIndex = 1

    End Sub
    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        'make sure any outstanding edits are committed to the datatables
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()
        'then save datatable changes to database        
        Me.ApplicantsTableAdapter.Update(Me.SYEP2007DataSet.Applicants)
        Me.JobTitlesTableAdapter.Update(Me.SYEP2007DataSet.JobTitles)

    End Sub
    Private Sub btnUpdatePosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdatePosition.Click

        Dim jobRow As DataRow()
        'use the currency manager to get the currently ...
        '... selected job in the jobs grid
        Dim jobsRow As DataRowView = CType(cmJobs.Current, DataRowView)
        'and save the job number
        Dim newJobNumber As Integer = CInt(jobsRow("keyJobTitleID"))
        'similar for the applicants
        Dim applicantsRow As DataRowView = CType(cmApplicants.Current, DataRowView)
        'check if this applicant already has a job
        If Not TypeOf (applicantsRow.Item("keyJobTitleID")) Is DBNull Then
            'if so, seek the relevant row from the datatable
            jobRow = dtJobs.Select("keyJobTitleID = " & Convert.ToString(applicantsRow.Item("keyJobTitleID")))
            'if there is one
            If jobRow.Length > 0 Then
                'it will be the first in the row array: update it
                Dim myVal As Integer = CInt(jobRow(0).Item("txtWorksiteJobTitlePositionsNumber"))
                myVal += 1 'or myVal = myVal + 1
                jobRow(0).Item("txtWorksiteJobTitlePositionsNumber") = myVal
            Else
                'if there isn't one ...
                MsgBox("Something wrong")
            End If
        End If
        'put the new job number in the applicant's record
        applicantsRow.Item("keyJobTitleID") = newJobNumber
        'decrement the number of jobs available
        'seek the relevant row from the datatable
        jobRow = dtJobs.Select("keyJobTitleID = " & newJobNumber)
        'if there is one
        If jobRow.Length > 0 Then
            'it will be the first in the row array: update it
            Dim myVal As Integer = CInt(jobRow(0).Item("txtWorksiteJobTitlePositionsNumber"))
            myVal -= 1 'or myVal = myVal - 1
            jobRow(0).Item("txtWorksiteJobTitlePositionsNumber") = myVal
        Else
            'if there isn't one ...
            MsgBox("Something wrong")
        End If

        ''commit the edits - this is necessary where ...
        ''... they have been done by via the currency ...
        ''... manager's Current record, rather than ...
        ''... (as above) in the datatable itself
        cmApplicants.EndCurrentEdit()
        cmJobs.EndCurrentEdit()

        'run the sub to update the jobs numbers displays
        updateTotals()

        'get the job title for this applicant
        Dim dgvr As DataGridViewRow = ApplicantsDataGridView.CurrentRow
        fillInTitle(dgvr)



    End Sub

    Private Sub btnCancelPosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelPosition.Click
        Me.Close()
    End Sub

    Private Sub cmJobs_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmJobs.PositionChanged
        'the jobs currency manager was declared WithEvents ...
        '... to make it easy to update the jobs numbers ...
        '... displays when a different job was selected ...
        '... in the grid
        If cmJobs.Count > 0 Then
            updateTotals()
        End If
    End Sub

    Private Sub updateTotals()
        If cmJobs.Count = 0 Then
            txtAvailable.Text = ""
            txtTaken.Text = ""
            txtTotal.Text = ""
            MsgBox("No more jobs")
            Exit Sub
        End If
        'use the currency manager to get the currently ...
        '... selected job in the jobs grid
        Dim jobsRow As DataRowView = CType(cmJobs.Current, DataRowView)
        'that says how many of that job are available
        Dim available As Integer = CInt(jobsRow.Item("txtWorksiteJobTitlePositionsNumber"))
        'get the job ID from that row
        Dim thisJob As Integer = CInt(jobsRow.Item("keyJobTitleID"))
        'use the job ID to find how many applicants ...
        '... already have that job
        Dim taken As Integer = CInt(dtApplicants.Compute("Count(keyJobTitleID)", "keyJobTitleID = " & thisJob))
        'the total is the sum of those two
        Dim total As Integer = available + taken
        'display the results
        txtAvailable.Text = available.ToString
        txtTaken.Text = taken.ToString
        txtTotal.Text = total.ToString
    End Sub

    Private Function getTitleFromID(ByVal ID As Integer) As String
        'Temporary line for debugging purposes
        'If that is reporting 0, then we know the problem is with the datatable.  
        'If it is reporting more than that, then the problem is with either the value
        'that is being passed to the function,
        'or with the syntax or references in the select statement.
        ' 'Debug.WriteLine(dtJobs.Rows.Count)

        'use datatable filter to return only rows with this ID
        Dim dr As DataRow() = dtJobs.Select("keyJobTitleID = " & ID)
        'check if there are any such rowsI
        If dr.Length > 0 Then
            'if yes, there should only be one - in position 0
            'return the value in the JobNmae field from that
            Return CStr(dr(0)("txtWorksiteJobTitle"))
        Else
            'otherwise, return empty string
            Return ""
        End If
    End Function

    Private Sub fillInTitle(ByVal dgvr As DataGridViewRow)
        'check if there is a value in the third cell ...
        '... (index 2, which is the "Job" field ...
        '... in this row from the datagridview
        If TypeOf dgvr.Cells(2).Value Is DBNull Then
            'if not, then there is no Job Title
            dgvr.Cells(4).Value = ""                    'I added the ProgramID field and changed Cells(3) to Cells(4) (added on line 55)
        Else
            'if there is, use it to get the Job Title
            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))   'I added the ProgramID field and changed Cells(3) to Cells(4)
        End If
    End Sub
    Private Sub ApplicantsDataGridView_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles ApplicantsDataGridView.DataError
        Debug.WriteLine(e.ColumnIndex)
        Debug.WriteLine(e.RowIndex)
        Debug.WriteLine(ApplicantsDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
        Debug.WriteLine(ApplicantsDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).EditedFormattedValue)
        e.ThrowException = True
    End Sub
End Class

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-04-19 at 14:08:36ID22522580
Tags

datagridview

,

fill

,

dataset

Topics

Microsoft Visual Basic.Net

,

MS SQL Server

,

Visual Studio

Participating Experts
4
Points
500
Comments
61

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. DataSet and DataRow
    I'm trying to add results from SP (sql) row by row to a desired dataset. This is the error: System.NullReferenceException: Object reference not set to an instance of an object. The line that is marked: dsTotalFeatures.Tables[0].Rows.Add(dr); This is the Code : { ...
  2. Copy Information from datagridview to dataset or from a dat…
    How do I copy information from datagridview to dataset or from a datatable to one of the tables in dataset. Please help. Thanks.
  3. VB.net Datagridview - updating the dataset with datagrid…
    Hi I've got a datagridview displaying a dataset. Unfortunately when getting the Dataset (mycontrol.thedataset), the last row typed is missed UNLESS the user has pressed enter to move onto another row. How do I update the dataset with the changes the user made on the d...
  4. Import one datarow from one dataset datatable to another d…
    I'm working with Crystal reports and usually import an entire dataset (100 rows) into the report. However, this time I need to import only one row from the dataset into the report. My thoughts are import one row into another dataset that's bound to the report. Q. How...
  5. Sorting datagridview as well as binding dataset
    I have bind the dataset with the datagridview while i sort the rows in the datagridview the dataset table also should short but it is not sorting. after sorting the datagridview if i click the 1st row of datagridview it is showing the lastrecord in the dataset. I need to sor...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: dtoddPosted on 2007-04-19 at 14:13:18ID: 18942442

Hi,

Does the datagrid have a bind() method?

Which version of dot net framework are you using?

What do you have to do in your form when it is running to get the data to appear?

Regards
  David

 

by: megninPosted on 2007-04-19 at 14:30:34ID: 18942535

I'm using Visual Studio 2005, so .NET 2.0.

The DataGridView, "ApplicantsDataGridView", is bound to an "ApplicantsBindingSource" in the designer.

The DataGridView is populated from a ApplicantsBindingSource and ApplicantsTableAdapter.  I'm just learning so I'm not too clear on eaches roles.

On the designer I just dragged the Table I wanted to use from the DataSet onto the form and and the default DataGridView was created and populated.

Now I'm trying to do some updates and adding one column programatically and doing some calculations then writing some data back to the database.

When I open the app after closing it the original data is there, but the new updates are not filling back and showing up in the DataGridView column where they were added the last time I ran the app.
The data is going into the database and it's also in the DataSet, just not going back to the DataGridView column.

Thanks.
David M.

 

by: dtoddPosted on 2007-04-19 at 14:34:27ID: 18942572

Hi David,

I've used the DataGrid in 2.0 (C#) and foudn the easiest way was to generate the select on the view myself, and then bind the datagrid.

IIRC (its been a while) there is a bind() method. Are the books on line or MSDN library any help at this point?

I found that a lack of clear cross referencing a bit of a pain when I sorted out my code ...

HTH
  David T

 

by: Priest04Posted on 2007-04-19 at 14:36:17ID: 18942583

Do you see old values in datagridview or it is empty? Put a breakpoint on Form1_Load event, close the form and reopen it to see if fires.

Also,

Private dtApplicants As New DataTable("Applicants")
Private dtJobs As New DataTable("Jobs")

are used as reference to datatables in dataset, so no need for New keyword.

Private dtApplicants As DataTable()
Private dtJobs As DataTable()

Goran

 

by: SanclerPosted on 2007-04-19 at 15:22:30ID: 18942808

David

One thing that you could try is to add this new line where shown

        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
            cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE
        Next

When the fillInTitle sub was being called in the previous versions it was always on a single record basis.  In normal operation the currency manager would therefore be be moved to another applicants record - so automtically ending the current edit - before the sub was called again.  Here, however, it is being called in a loop, and the automatic calling of endcurrentedit may not be happening.

If that doesn't work, I agree with Goran that you need to put a breakpoint in to see what's happening.

If - I'm not sure about this - nothing is showing in your datagridview - then it ought to be in the form load event.  But if, as I suspect, it is just that the job titles column is not being filled in, I would put it on the first line of the fillInTitle sub, here

       If TypeOf dgvr.Cells(2).Value Is DBNull Then

and then single step from there.  Do you know how to do that?

If you're happier using debug output to see what's happening, put something like this

            Debug.WriteLine("Cell 2 = " & dgvr.Cells(2).Value)

immediately before this

            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))

and

            Debug.WriteLine("Cell 4 = '" & dgvr.Cells(4).Value & "'")

immediately after that line.  If you get no debug output at all we will know either that the sub is not being called or it is being passed null values by every row.  If you get values in Cell 2 but not in Cell 4, we will know to look in the getTitleFromID sub.  If you get values in both, then it looks like its something about the datagridview set-up.

Roger

 

by: SanclerPosted on 2007-04-19 at 15:34:08ID: 18942865

Just reflecting on that first point - about the currency manager and endcurrentedit - the currency manager shouldn't have anything to do with this cell, because it's unbound.  That is not to say that you shouldn't try it anyway, because the internal workings of datagridviews and their relationships with currency managers (particularly where there are some unbound columns) are still very obscure to me.  But if it doesn't work, the other thing to try, on generally the same line of thinking, would be

            ApplicantsDataGridView.EndEdit()

instead of

            cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE

Roger

 

by: cpkilekofpPosted on 2007-04-19 at 16:21:20ID: 18943052

Everyone should consult these pages with special attention paid to the definition and usage of the BindingSource object:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx

http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx

I point this out as there is no reference to a BindingSource in our querent's code though it is explicitly used in a MS example.  Also, by some change could this DataGridView be persistent in some fashion, say, to a local XML data set?  This would account for the database showing changed data and the application not showing these changes.

 

by: SanclerPosted on 2007-04-20 at 01:17:15ID: 18944813

David

I've now had a chance to extend, and test, my original demo using a database rather than making dummy data in the app itself.  Apart from converting the source of the data, and providing for the database to be updated on form closing, the only change I made to my code was to add - as you have done - these lines

        'get the job titles for the applicants
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
        Next

at the end of my form load sub.

In running the revised demo, alterations made in one session appear correctly in the datagridviews when re-opening.

This suggests to me that the EndCurrentEdit or EndEdit additions I discussed above are not necessary, and won't correct your problem.  I reckon it may be something about how you are setting up the DataGridView.

With that in mind, one other debugging step that you might like to consider is - temporarily - to comment out these lines

        'hide the applicant ID
        ApplicantsDataGridView.Columns(0).Visible = False
        'hide the job ID ...
        ApplicantsDataGridView.Columns(2).Visible = False
        'hide the ProgramID column in Applicants DGV
        ApplicantsDataGridView.Columns(3).Visible = False

so that you can inspect what data is actually being placed where in your grid.

Roger

 

by: megninPosted on 2007-04-20 at 03:22:59ID: 18945208

Hi David T.,

[quote]"I've used the DataGrid in 2.0 (C#) and found the easiest way was to generate the select on the view myself, and then bind the datagrid."[/quote]

Could you show me an  example of how to do that.  I would really like to learn to do as much in code as I can rather than in the Designer.  I'm using VB in VS2005, but an example in C# even would still be helpful.

Thank you!
David M.

 

by: megninPosted on 2007-04-20 at 03:32:42ID: 18945251

Hi again Goran.  I'm happy to see you again.

When I open the app the Job Title fields in the Applicant DGV are blank.  No old data.  The TextBoxes, however, are displaying the correct total, taken and available amounts.

Thanks for the tip about the "New" keyword!  I guess New is used when instantiating a new object, not when referencing an existing object.

David M.

 

by: megninPosted on 2007-04-20 at 03:49:40ID: 18945316

cpkilekofp,

Thank you.  I've been looking for a good reference on DataGridViews and BindingSource.

In my ApplicantDataGridView and JobTitleDataGridView I have the BindingSource set in the Designer, VS2005.  I created the DataGridViews in the designer by dragging the tables from the DataSet window.  Forgive me if I'm missing something, I'm still not very familiar with these processes.  The DataSet is coming from a MS SQL Server 2000 database.  
Is the DataSet in my Data Sources window an XML DataSet or would I have had to create an XML DataSet some other way?  I mean, I do have a local (to the app) DataSet, but I'm not sure if it's an "XML DataSet".  I know what XML is, but not how to create an XML DataSet from SQL Server database... unless that's what I already have. ;-}

Thanks.
David M.

 

by: megninPosted on 2007-04-20 at 03:54:19ID: 18945334

Roger,

I'll try your suggestions when I get to work this morning.  

Thank you for taking the extra time and trouble to set up an actual database for this.  I'm really learning a lot from this session and I sincerely appreciate all your help!

David M.

 

by: cpkilekofpPosted on 2007-04-20 at 05:19:53ID: 18945670

>Is the DataSet in my Data Sources window an XML DataSet or would I have had
>to create an XML DataSet some other way?  I mean, I do have a local (to the
>app) DataSet, but I'm not sure if it's an "XML DataSet".  I know what XML is, but
>not how to create an XML DataSet from SQL Server database... unless that's
>what I already have. ;-}

Based on your report of the data in the grid view remaining unchanged, I guessed that the binding wasn't taking place properly after an update, and that a local data store was being used in its place.  Such a data store would most likely be an XML dataset, and would appear as a file with an extension of .XSD in your application directory.  XML is one option for persisting a DataSet locally, so read "XML DataSet" as "a file in XML format containing a copy of the data last held in the DataSet".

 

by: Priest04Posted on 2007-04-20 at 08:00:20ID: 18946932

Few things to clarify: the problem is in ApplicantsDataGridView, right? If so, why are you using BindingSource with ApplicantsDataGridView, and then in code you create Currency manager and re-set ApplicantsDataGridView.DataSource property? Sine you are doing it in code, no need for designer BindingSource component.

Goran

 

by: megninPosted on 2007-04-20 at 08:19:12ID: 18947092

Hi Goran.

I originally created the DataGridViews in the designer so they automatically got the BindingSource component.  When you and Roger started helping me I asked Roger if I should remove the BindingSource component from the designer or if it would cause any problems being there.  I think he said the the bindings in code would override it anyway so it shouldn't cause any problems.

If its not going any good, anyway, then I'll remove it from the designer view and see if that makes any difference.

Thank you for pointing that out!

David M.

 

by: cpkilekofpPosted on 2007-04-20 at 08:19:26ID: 18947096

Goran's point is a real head-slapper.  You should correct this immediately.

 

by: megninPosted on 2007-04-20 at 08:24:20ID: 18947140

Goran,

You suggested putting a break point in the Form1_Load to see if it fires.
I do have a TabControl1.SelectedIndex = 1 as the last statement in the Form1_Load to make the second tab the active one when it opens.  That's working so the Form1_Load must be firing.

David

 

by: megninPosted on 2007-04-20 at 11:01:48ID: 18948349

I broke it for a little while there.  I removed the BindingSource from the DGV in the designer and I started getting, first, ""Custodian" is not a valid value for Int32" on this line: dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value)), then "" is not a valid value for Int32 on this line: dgvr.Cells(4).Value = "".

I've gotten that resolved now.  In the ApplicantsDataGridView I had removed all the  columns in the designer except for 3 when it was working.  When I removed the BindingSources then the columns didn't match and when I put the BindingSource back with all the columns that threw it off as well.

I'm got it back to a working state and will work on Removing the BindingSource from the designer again and implementing all the other suggestions above, one step at a time this time.

So, I've got a bit more work to do before I ask for more help.  I'll do my best to figure out what to do next on my own.  I'll let you know how it works out.

I hope you all have a good weekend if I don't talk to you again today.

Thank you again for all your help!!!!

David M.

 

by: SanclerPosted on 2007-04-20 at 11:48:51ID: 18948664

David

If it's not too late, before you remove the bindingsource and/or do anything else about adding or removing columns, please try the suggestion I made earlier.

>>
With that in mind, one other debugging step that you might like to consider is - temporarily - to comment out these lines

        'hide the applicant ID
        ApplicantsDataGridView.Columns(0).Visible = False
        'hide the job ID ...
        ApplicantsDataGridView.Columns(2).Visible = False
        'hide the ProgramID column in Applicants DGV
        ApplicantsDataGridView.Columns(3).Visible = False

so that you can inspect what data is actually being placed where in your grid.
<<

There are all sorts of things that are "wrong", or at least "odd", about your program as it stands.  But that was simply as result of us cobbling together bits and pieces of different approaches so that, quickly, you could get something that WORKED.  And, it appears, it did work to the extent of allowing allocation of jobs to applicants and saving the results of that to the database.  I can see no fundamental reason why it should not bring that saved data back again - even with the oddities remaining in your program.  If we can find out what the quirk is, with the current setup, that is stopping the data - which you say is coming back - being properly displayed, it will still work.  My fear is that, if you start altering all sorts of other things - even though thay are odd, or even plain "wrong" - it may stop working.

It's your choice.  If you want a program that's "correct" then I agree with many of the suggestions that have been made.  But if you want one that continues to work without major re-writing I think you ought to concentrate your efforts on finding out why, exactly, the code you originally posted is not working.  And to do that, you need to find out what the current code is actually doing by some sort of debugging.

Roger

 

by: megninPosted on 2007-04-20 at 12:05:07ID: 18948769

Roger,

[quote]
 But if, as I suspect, it is just that the job titles column is not being filled in, I would put it on the first line of the fillInTitle sub, here

       If TypeOf dgvr.Cells(2).Value Is DBNull Then

and then single step from there.  Do you know how to do that?
[/quote]

You are correct.   The other data is there (Kids names, etc.), it's just the JobTitles column is not being filled in.
I put a break point on the line above and single steped from there.  It cycled through each of the dgvr rows and the "Autos" window showed each of the JobTitleIDs for the rows (Kids) that had been assigned, e.g. dgvr.Cells(4).Value = 182417 and so forth with all the correct ID numbers.

I'll continue to work through the suggestions above to see what I come up with.

Thanks,
David

 

by: megninPosted on 2007-04-20 at 12:12:53ID: 18948828

Oh, I tried the new line:
[quote]
One thing that you could try is to add this new line where shown

        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
            cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE
        Next
.
.
.
If that doesn't work, I agree with Goran that you need to put a breakpoint in to see what's happening.
[/quote]

It had no apparent affect.  Still no data in Job Title column when the app opens.
I made the JobTitleID column (index 0) visible again so I could see the rows that should have Job Titles.

David

 

by: SanclerPosted on 2007-04-20 at 12:16:57ID: 18948868

>>
e.g. dgvr.Cells(4).Value = 182417
<<

That's wrong!!!  Look at this line

            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))   'I added the ProgramID field and changed Cells(3) to Cells(4)

dgvr.Cells(4).Value is supposed to be what is filled with the job TITLE.  The ID numbers are supposed to be in dgvr.Cells(2).Value

Roger

 

by: SanclerPosted on 2007-04-20 at 12:22:37ID: 18948907

If it would be easier, you could simply change the references in the sub rather than rejigging the order of the columns.

Roger

 

by: megninPosted on 2007-04-20 at 12:24:48ID: 18948919

Roger, I put the two Debug lines in as you suggested at 6:22 pm EST on 04.19.2007.

I'm not sure what to look for, but this is the entire contents of the Debug window after running it.  I assume this means that there was no debug info since I didn't see anything about "Cell 2 =" or "Cell 4 =".  So I'll start looking in the area you suggested for that case.

Debug:
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\0-VisualStudioProjects\SYEP07\ADMIN_Backup\Admin\bin\Release\Admin.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x8e8 has exited with code 0 (0x0).
The thread 0xee4 has exited with code 0 (0x0).
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\0-VisualStudioProjects\SYEP07\ADMIN_Backup\Admin\bin\Release\Admin.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[5960] Admin.vshost.exe: Managed' has exited with code 0 (0x0).
The thread 0x106c has exited with code 0 (0x0).
The thread 0x2d0 has exited with code 0 (0x0).
'Admin.vshost.exe' (Managed): Loaded 'C:\0-VisualStudioProjects\SYEP07\ADMIN_Backup\Admin\bin\Release\Admin.exe', Symbols loaded.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Accessibility\2.0.0.0__b03f5f7f11d50a3a\Accessibility.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.


David

 

by: SanclerPosted on 2007-04-20 at 12:28:26ID: 18948942

David

PLEASE READ MY LAST TWO POSTS

Roger

 

by: megninPosted on 2007-04-20 at 12:30:56ID: 18948957

I put the break point back in and stepped through again.  I noticed that dgvr.Cells(2).Value always showed the correct JobtitleID (an integer), but dgvr.Cells(4).Value always showed "Nothing".

David

 

by: SanclerPosted on 2007-04-20 at 12:35:23ID: 18948983

David

You said about 25 minutes ago

>>
I put a break point on the line above and single steped from there.  It cycled through each of the dgvr rows and the "Autos" window showed each of the JobTitleIDs for the rows (Kids) that had been assigned, e.g. dgvr.Cells(4).Value = 182417 and so forth with all the correct ID numbers.
<<

You are now saying

>>
I put the break point back in and stepped through again.  I noticed that dgvr.Cells(2).Value always showed the correct JobtitleID (an integer), but dgvr.Cells(4).Value always showed "Nothing".
<<

Which is it?

Roger

 

by: SanclerPosted on 2007-04-20 at 12:47:33ID: 18949069

>>
I put a break point on the line above and single steped from there.  It cycled through each of the dgvr rows and the "Autos" window showed each of the JobTitleIDs for the rows (Kids) that had been assigned, e.g. dgvr.Cells(4).Value = 182417 and so forth with all the correct ID numbers.
<<

What you need to look for is not only the values shown but also where the program flow goes.  So, if dgvr.Cells(2).Value was DBNull it would have gone to this line

            dgvr.Cells(4).Value = ""

if it was not DBNull it would have gone to this line

           dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))

Which line did it go to?  If it was the latter, it should then have gone into the getTitleFromID sub.  Did it do that?  If it did, what happened there?

Roger

 

by: megninPosted on 2007-04-20 at 12:52:02ID: 18949098

Roger,

Yeah, I finally got the column order rejigging straightened out.

I did find something else while stepping through the code in debug mode.

As I step through, starting at:
• If TypeOf dgvr.Cells(2).Value Is DBNull Then

This Function executes:
    Private Function getTitleFromID(ByVal ID As Integer) As String
        'use datatable filter to return only rows with this ID
        Dim dr As DataRow() = dtJobs.Select("keyJobTitleID = " & ID)
        'check if there are any such rowsI
        If dr.Length > 0 Then
            'if yes, there should only be one - in position 0
            'return the value in the JobNmae field from that
            Return CStr(dr(0)("txtWorksiteJobTitle"))
        Else
            'otherwise, return empty string
            Return ""
        End If
    End Function

But, as this line is executed:
Return CStr(dr(0)("txtWorksiteJobTitle"))
the "Autos" window displays:
dr  Value = {Length=1}

Item  Value = "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."

Does that give any clues as to what's going on?  I'm afraid it's beyond my experience.

David

 

by: Priest04Posted on 2007-04-20 at 13:03:20ID: 18949174

If

dgvr.Cells(4).Value =""

then it means that no rows match this ID in getTitleFromID, so it is returning an empty string. You need to make sure that there are rows in dtJobs that match ID you are passing

From the form load event, I see that you are filtering dtJobs to showonly jobs that remain available. Maybe you need to do this filtering after you populate data. So try putting

dvjobs.RowFilter = "txtWorksiteJobTitlePositionsNumber > 0"

at the end of Form_load

Goran

 

by: megninPosted on 2007-04-20 at 13:06:14ID: 18949197

I'm sorry.  In my first breakpoint message
>>
JobTitleIDs for the rows (Kids) that had been assigned, e.g. dgvr.Cells(4).Value = 182417 and so forth
<<
Cell(2) actually contains the integer IDs.  Cells(2) does show the "182417" or whatever ID.  Cells(4) is showing "Nothing".

I'll check the program flow and see what happening...

David

 

by: megninPosted on 2007-04-20 at 13:19:53ID: 18949286



>>
What you need to look for is not only the values shown but also where the program flow goes.  So, if dgvr.Cells(2).Value was DBNull it would have gone to this line
            dgvr.Cells(4).Value = ""
if it was not DBNull it would have gone to this line
           dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))
Which line did it go to?  If it was the latter, it should then have gone into the getTitleFromID sub.  Did it do that?  If it did, what happened there?
<<

When the app starts dgvr.Cells(2).Value is not null, the first few rows contain ID values.  the next line to execute is:
dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))

then the next line, in the getTitleFromID Function, executed is:
Dim dr As DataRow() = dtJobs.Select("keyJobTitleID = " & ID)

then it flows through:
        If dr.Length > 0 Then
            Return CStr(dr(0)("txtWorksiteJobTitle"))

and back to:
dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))

then:
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)

and finally back to:
If TypeOf dgvr.Cells(2).Value Is DBNull Then

where it starts over for another loop and does the same again.

It looks like the flow is going correctly.

David



 

by: megninPosted on 2007-04-20 at 14:27:42ID: 18949748

I put a break point in the Form1_Load and stepped through the
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)
            'cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE 'This had no apparent affect.  It didn't cause the Job Title column to fill in on form load
            'ApplicantsDataGridView.EndEdit()  'This didn't do it either.
        Next

The flow followed exactly like it does when fillInTitle(dgvr) is called from btnUpdatePosition_Click.

To me, it looked like it was doing the same thing in the Form1_Load as it was doing in the btnUpdatePosition to put the Job Title in Cells(4).  The only difference was that when the fillInTitle sub finished from the button the Job Title popped into  cell 4.  The same flow occurred in the Form1_Load, only no Job Title appeared in cell 4.  ?

David

 

by: megninPosted on 2007-04-20 at 14:30:18ID: 18949765

Goran,

I've put dvjobs.RowFilter = "txtWorksiteJobTitlePositionsNumber > 0" at the very end of the Form1_Load.  It didn't make any change.

David

 

by: SanclerPosted on 2007-04-20 at 14:39:58ID: 18949828

Sorry, I got sidetracked.

In the getTitleFromID Function will you please alter this

        If dr.Length > 0 Then
            Return CStr(dr(0)("txtWorksiteJobTitle"))

to this

        If dr.Length > 0 Then
            Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
            Return s

put a breakpoint on the line

            Return s

and check what the value is of s?

I should be about now for about another hour.  Let's see if we can knock this on the head.

Roger

 

by: Priest04Posted on 2007-04-20 at 15:27:16ID: 18950050

Maybe it would be better to put a breakpoint on first line in this part of code

 If dr.Length > 0 Then
            'if yes, there should only be one - in position 0
            'return the value in the JobNmae field from that
            Return CStr(dr(0)("txtWorksiteJobTitle"))
        Else
            'otherwise, return empty string
            Return ""
        End If

could be dr.Length=0 and the code jumps to ELSE

Goran

 

by: SanclerPosted on 2007-04-20 at 15:33:38ID: 18950067

Goran

Yes, but David has said he's getting past that

>>
then it flows through:
        If dr.Length > 0 Then
            Return CStr(dr(0)("txtWorksiteJobTitle"))

and back to:
dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))
<<

If it never breaks on the line I've suggested then we know it's not getting that far, it's always going to ELSE.  But if, as David says, it is getting that far, then what is being returned?

Roger

 

by: SanclerPosted on 2007-04-20 at 16:25:39ID: 18950213

I'm off to bed: it's well after midnight in the UK.

As I've said, my demo app with essentially the same code works OK, so I reckon the problem lies in the detail of your data setup.  But identifying it requires a debugging approach, and one that develops in different ways depending on the results at each stage.  It's difficult, and time consuming, trying to do that remotely.  So, if it doesn't get sorted out within the next post or two, I suggest you zip up the whole project and post it to

    http://www.ee-stuff.com/

and then post the resulting URL back here.  We won't have the data, but the dataset files included in the project will hopefully give us sufficient indication of what's what to see where the problem might lie.

Goodnight.

Roger

 

by: megninPosted on 2007-04-21 at 14:38:53ID: 18952686

I put the "Dim s ... Return s" code and breakpopint, <BP>, in and stepped through it.  I numbered the program flow as it went.  Below the Breakpoint, <BP> it starts with <1> and so on until the currently assigned JobTitles run out.

Form1_Load....
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
<4><12><20><28><36><40><44><48>            fillInTitle(dgvr)
            'cmApplicants.EndCurrentEdit() '<<< NEW LINE HERE 'This had no apparent affect.  It didn't cause the Job Title column to fill in on form load
            'ApplicantsDataGridView.EndEdit()  'This didn't do it either.
        Next
End Sub

    Private Function getTitleFromID(ByVal ID As Integer) As String
        'Temporary line for debugging purposes
        'If that is reporting 0, then we know the problem is with the datatable.  
        'If it is reporting more than that, then the problem is with either the value
        'that is being passed to the function,
        'or with the syntax or references in the select statement.
        Debug.WriteLine(dtJobs.Rows.Count)

        'use datatable filter to return only rows with this ID
<7><15><23><31>        Dim dr As DataRow() = dtJobs.Select("keyJobTitleID = " & ID)
        'check if there are any such rowsI
 <BP><8><16><24><32>       If dr.Length > 0 Then
            'if yes, there should only be one - in position 0
            'return the value in the JobNmae field from that
            '          Return CStr(dr(0)("txtWorksiteJobTitle"))
 <1><9><17><25><33>           Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
 <2><10><18><26><34>           Return s
        Else
            'otherwise, return empty string
            Return ""
        End If
    End Function

    Private Sub fillInTitle(ByVal dgvr As DataGridViewRow)
        'check if there is a value in the third cell ...
        '... (index 2, which is the "Job" field ...
        '... in this row from the datagridview
<5><13><21><29><37><41><45><49>        If TypeOf dgvr.Cells(2).Value Is DBNull Then
            'if not, then there is no Job Title
<38><42><46><50>            dgvr.Cells(4).Value = ""
        Else
            'if there is, use it to get the Job Title
            Debug.WriteLine("Cell 2 = " & CInt(dgvr.Cells(2).Value))  'I didn't see anything unusual in the debug window when this ran.
<3><6><11><14><19><22><27><30><35><39><43><47><51 end>            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))  
            Debug.WriteLine("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'")
        End If
    End Sub
   
At point <38> the kid on that row has not been assigned a JobTitle and Function getTitleFromID is no longer in the loop.
"s" never showed any value.  It never showed up in the Autos window and I never got anything when I hovered my mouse over it.

David

 

by: megninPosted on 2007-04-21 at 15:09:49ID: 18952761

I tried several times to upload my project files.  The admin.zip file is 3.8MB and the upload instructions said the max size was 4MB, but every time I tried, it told me the file was TOO SMALL.  I double checked the file and the size, still no go.

David

 

by: SanclerPosted on 2007-04-21 at 15:15:22ID: 18952772

David

What this appears to mean is that there is nothing (or, probably, there is an empty string "") in the column called "txtWorksiteJobTitle" in that row in the datatable dtJobs which has the value in its column called "keyJobTitleID" which matches the value in the relevant DataGridRow's Cells(2).Value.

To check if that is the case, will you please temporarily add a button to your form and put this code in its button_click event

   Dim st As String
   For Each dr As DataRow In dtJobs.Rows
       st &= cStr(dr("keyJobTitleID")) & " = |" & Cstr(dr("txtWorksiteJobTitle")) & "|" & vbCrLf
   Next

and report the final value of st.  It's up to you whether you get it with a

   Debug.WriteLine(st)

or a

   MsgBox(st)

after the Next, or check it out with a breakpoint and reading the value.

Roger

PS, forget the upload for the moment.

 

by: SanclerPosted on 2007-04-22 at 07:36:49ID: 18954214

David

Now that I'd studied you last post in detail, there are three things in it that I just do not understand.

First, you say, at the end

>>
"s" never showed any value.  It never showed up in the Autos window and I never got anything when I hovered my mouse over it.
<<

and yet the code clearly, as you report it, went through the lines in which "s" is declared and used

<BP><8><16><24><32>       If dr.Length > 0 Then
            'if yes, there should only be one - in position 0
            'return the value in the JobNmae field from that
            '          Return CStr(dr(0)("txtWorksiteJobTitle"))
 <1><9><17><25><33>           Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
 <2><10><18><26><34>           Return s

So, I reckon s must have been something, even if it was only the empty string - "".  To check this, put this line

           MsgBox("|" & s & "|")

between

           Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
and

           Return s

Then, even if "s" is an empty string, the messagebox should show "||": and using a message box should overcome any problems about reading debug output.

Second, in this piece of code

        If TypeOf dgvr.Cells(2).Value Is DBNull Then 'line 1
            'if not, then there is no Job Title
            dgvr.Cells(4).Value = "" 'line 2
        Else
            'if there is, use it to get the Job Title
            Debug.WriteLine("Cell 2 = " & CInt(dgvr.Cells(2).Value))
            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value)) 'line 3  
            Debug.WriteLine("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'") 'line 4
        End If

what I have marked as line 1 always fires if the sub is called.  The next line to fire will be what I have marked as line 2 if, and only if, there is a DBNull.  If there is not a DBNull then the next line to fire (leaving out debug output lines) will be what I have marked as line 3.  That is, after line 1 the next line will be EITHER line 2 OR line 3, it cannot be both.  But  for the last four calls of the sub - starting with <37> - the sequence you are reporting is line 1, line 2, line 3.  That is, you are reporting BOTH line 2 AND line 3 as firing.

Third, you have not marked line 4 as firing even when line 3 has fired.  I had assumed, originally, that that was because you had not bothered to mark any of the Debug.WriteLine lines even though they had fired appropriately.  But I don't see how the line

            Debug.WriteLine("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'") 'line 4

could have fired (or perhaps even compiled) without producing an error.  This is because - presumably because you still have Option Strict On - you changed what I originally suggested, which was

            Debug.WriteLine("Cell 4 = '" & dgvr.Cells(4).Value & "'")

But you cast it to an Integer - using CInt() - when the setting needed a String - using CStr().  So, was that really, as written, part of the code?  And, if so, what happened after line 3 had been executed?  Did the flow get to line 4?  If so, was an error thrown?  If not, and the line did execute OK, what was the result?

I appreciate that some of these comments/questions may appear to be excessively nit-picking.  But I have remarked previously that it's difficult trying to debug remotely.  It changes from difficult to impossible unless we know EXACTLY what is happening.  The sort of description you've given can be very valuable if it's exactly right, but even the slightest discrepancy between what actually happens and what you report as happening can lead us astray when we get down to this level of detail.

Let me stress that I am not saying that what you reported is wrong.  It may be right but, if so, there are all sorts of issues which suggest that something really radical is wrong.  At the very least I would want absolute and unconditional guarantee that that is the case before I would even start to think about - let alone code to test - what those might be.

Roger

 

by: megninPosted on 2007-04-22 at 13:59:15ID: 18955176

Thanks again Roger.

I thought something looked funny when I was stepping through the code, but I don't think I know the explanation.

Before I add the button, I'm going to quote part of your last post and try to address each of your questions within it.


[quote]
David

Now that I'd studied you last post in detail, there are three things in it that I just do not understand.
.
.
.
Then, even if "s" is an empty string, the messagebox should show "||": and using a message box should overcome any problems about reading debug output.

Second, in this piece of code

        If TypeOf dgvr.Cells(2).Value Is DBNull Then 'line 1
            'if not, then there is no Job Title
            dgvr.Cells(4).Value = "" 'line 2
        Else
            'if there is, use it to get the Job Title
            Debug.WriteLine("Cell 2 = " & CInt(dgvr.Cells(2).Value))
            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value)) 'line 3  
            Debug.WriteLine("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'") 'line 4
        End If

what I have marked as line 1 always fires if the sub is called.  The next line to fire will be what I have marked as line 2 if, and only if, there is a DBNull.  If there is not a DBNull then the next line to fire (leaving out debug output lines) will be what I have marked as line 3.  That is, after line 1 the next line will be EITHER line 2 OR line 3, it cannot be both.  But  for the last four calls of the sub - starting with <37> - the sequence you are reporting is line 1, line 2, line 3.  That is, you are reporting BOTH line 2 AND line 3 as firing.
<<<
Roger, I started stepping at the <BP>, hitting F11 and marking down each line of code that the yellow highlighting came to rest on.  I noticed that both "line 2" and "line 3" seemed to be firing so I ran several more cycles to make sure I hadn't recorded it incorrectly.
>>>

Third, you have not marked line 4 as firing even when line 3 has fired.  I had assumed, originally, that that was because you had not bothered to mark any of the Debug.WriteLine lines even though they had fired appropriately.
<<< I marked the lines exactly as the yellow highlighting came to rest on them.  I marked every line that was highlighted, one line at a time.  I just figured that it didn't stop on Debug lines.
>>>
 But I don't see how the line

            Debug.WriteLine("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'") 'line 4

could have fired (or perhaps even compiled) without producing an error.  This is because - presumably because you still have Option Strict On - you changed what I originally suggested, which was

            Debug.WriteLine("Cell 4 = '" & dgvr.Cells(4).Value & "'")

But you cast it to an Integer - using CInt() - when the setting needed a String - using CStr().  
<<<
When I first entered 'line 4' I got an error saying because Option Strict was On it could not implicitly convert an object to an integer.  It gave me the option to add "Cint(" and the error went away.
>>>
So, was that really, as written, part of the code?  And, if so, what happened after line 3 had been executed?  
<<<
Flow went directly back up to Form1_Load ... fillInTitle(dgvr)
>>>
Did the flow get to line 4?  
<<<
It never touched line 4
>>>
If so, was an error thrown?  If not, and the line did execute OK, what was the result?
<<<
There were no errors through out execution.
>>>

I appreciate that some of these comments/questions may appear to be excessively nit-picking.  
<<<
Not at all.  I understand that you are trying to figure out what's going on with my code that you have so patiently and kindly been trying to fix for me and that what you had to start with was my very messed up code which I didn't even know how it worked.
>>>
But I have remarked previously that it's difficult trying to debug remotely.  It changes from difficult to impossible unless we know EXACTLY what is happening.  The sort of description you've given can be very valuable if it's exactly right, but even the slightest discrepancy between what actually happens and what you report as happening can lead us astray when we get down to this level of detail.
<<<
I tried to make my observation 100% accurate.  That's why I stepped through 50 steps.  I wanted to get that last loop several times because I thought it looked funny too.
>>>

Let me stress that I am not saying that what you reported is wrong.  It may be right but, if so, there are all sorts of issues which suggest that something really radical is wrong.  At the very least I would want absolute and unconditional guarantee that that is the case before I would even start to think about - let alone code to test - what those might be.

Roger

[/quote]

Roger, would you be able or willing to remote into my computer with "GoToMeeting"?  That the only remote control utility that I know for sure will work through our firewall and such.

Let me know when I should continue this onto another thread.

I apologize for this being so drawn out and frustrating and I do sincerely appreciate the extra help you've given me.

David

 

by: SanclerPosted on 2007-04-22 at 16:15:39ID: 18955436

David

Sorry, no, I would not be prepared to remote into your computer.  I only do things via Experts Exchange.

On the two program flow points - covering both lines 2 and 3, and not hitting the Debug.WriteLine line/s - I'm stumped.  I suppose the second of them may be something to do with some setting on your system, although I don't know what that could be.  But the first of them - running both parts of an Either/Or construct is so contrary to the fundamentals of program control that I have no idea what it could be.

That's the bad news.

The good news is that, first, as the covering both lines 2 and 3 only seems to happen when it doesn't matter - for jobs with nothing to be added to the job titles column - perhaps it doesn't matter.  Second, your comment that

>>
When I first entered 'line 4' I got an error saying because Option Strict was On it could not implicitly convert an object to an integer.  It gave me the option to add "Cint(" and the error went away.
<<

may provide the best clue yet to what is going wrong.  That implies that the value that has been put in dgvr.Cells(4) is an INTEGER.  If the Job Title had been returned, that would have been a STRING.  As that is the value that has come (via the getTitleFromID sub) from the dtJobs column referenced by "txtWorksiteJobTitle" it implies very strongly that that column is an INTEGER column, not a STRING column, and that the value that is being returned is an INTEGER, not the STRING Job Title you are expecting.  The button code, and/or the messagebox code, that I suggested earlier should check on that.  Will you please run either or both?

Roger

 

by: megninPosted on 2007-04-22 at 19:24:46ID: 18955978

Roger,

Thanks again.  Yes, I will do both as  soon as I get into the office tomorrow.

I see what you're saying about the data type of what's going in dgvr.Cells(4).  I'll check and see if there some disconnect between the data type of each of the columns and what they should be, what is in the database, what's in the DataSet and what I've expected them to be.

David

 

by: megninPosted on 2007-04-23 at 10:04:22ID: 18959850

Roger,

I added the button:
   Dim st As String
   For Each dr As DataRow In dtJobs.Rows
       st &= cStr(dr("keyJobTitleID")) & " = |" & Cstr(dr("txtWorksiteJobTitle")) & "|" & vbCrLf
   Next

I put a Break Point at the beginning of the For Each statement...

During execution of Sub fillInTitle:
dgvr.Cells(2).Value = 1248538 {Integer}
dgvr.Cells(4).Value = Nothing

Then during execution of Function getTitleFromID:
ID = 1248538
dr = Nothing
dtJobs.Rows.Count = 311

dr = {Length=1}
dr.Length = 1

s never showed up at all.  Dim s and Return s were both hit but nothing showed in the debug window for s.

then I clicked the new button and:
st = Nothing
vbCrLF = "[ ] [ ]"

...but when I put the MsgBox(st) in, I got a message box with the entire list of JobIDs and Titles, ending with the last one, 9966017.

I've never seen dgvr.Cells(4).Value = anything but "Nothing"
and s has never showned up with any value anywhere.  The line executes or appears to anyway but I never see any value for s, even when the execution is paused on either of the two lines (Dim s or Return s).

Sorry for the delay, it's Monday and programming is not my only duty. :-{

I'm going to move on to your next instructions now...  I wanted to get this update to you.

Thank you again!

David

 

by: SanclerPosted on 2007-04-23 at 11:24:09ID: 18960429

1)   What are you calling the "debug window"?  If you are looking at the "Output" window, then look at the "Immediate" window instead.  If you are looking at the "Immediate" window, then look at the "Output" window instead.

2)   Where are you reading the values of the variables from?

3)   If you are in Break mode (while single-stepping) what does the tool tip show if you hover the mouse over the s in this line

            Return s

4)   Have you tried

>>
put this line

           MsgBox("|" & s & "|")

between

           Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
and

           Return s

<<

yet?

No need to apologise for the delay.  I have no deadlines to meet ;-)

Roger

 

by: megninPosted on 2007-04-23 at 11:56:38ID: 18960656

I put:
MsgBox("Cell 4 = '" & CInt(dgvr.Cells(4).Value) & "'")
into Sub fillInTitle and it resulted in:
"Conversion from string 'Administrative assistant' to type 'Integer' is not valid.

David

 

by: Priest04Posted on 2007-04-23 at 12:09:38ID: 18960752

Why are you conerting it to int?

MsgBox("Cell 4 = '" & cstr(dgvr.Cells(4).Value) & "'")

 

by: megninPosted on 2007-04-23 at 12:38:02ID: 18960953

Roger,

1)     I've been looking at the "Autos" window mostly.  The "Output" window shows stuff like:
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x118c has exited with code 0 (0x0).
The thread 0x148c has exited with code 0 (0x0).
'Admin.vshost.exe' (Managed): Loaded 'C:\0-VisualStudioProjects\SYEP07\ADMIN_Backup\Admin\bin\Release\Admin.exe', Symbols loaded.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Accessibility\2.0.0.0__b03f5f7f11d50a3a\Accessibility.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Admin.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

The "Immediate" Window is blank.  I'm stepping through the code and the "Immediate" window stays empty.

2)      The "Autos" window always shows the values of the current variables.  Usually a list of 2 to 8 different variables and values showing at any given time while stepping through the code.

3)      Hovering over the line "Return s" does nothing at all.  I can move my mouse over another variable and it will display the value.  It just doesn't do or show anything.  "s" never appears in the "Auto" window either.  All the other variables and values show up there, but never "s".

4)      A message box pops up for each of the Job Titles that are assigned to someone.  One message box for each pops up in turn.  

weird

David

 

by: megninPosted on 2007-04-23 at 13:08:50ID: 18961164

Roger,

(I changed the "Cint" to "CStr".  Without "CStr" is says, "Option Strict" prohibits operands of type Object for operator "&")

I made an interesting observation...
With this code:

   Private Sub fillInTitle(ByVal dgvr As DataGridViewRow)
        If TypeOf dgvr.Cells(2).Value Is DBNull Then
            dgvr.Cells(4).Value = ""
        Else
            'if there is, use it to get the Job Title
            MsgBox("Cell 2 = " & CInt(dgvr.Cells(2).Value))
            dgvr.Cells(4).Value = getTitleFromID(CInt(dgvr.Cells(2).Value))
            MsgBox("Cell 4 = '" & CStr(dgvr.Cells(4).Value) & "'")
        End If
    End Sub

and this in place :
            Dim s As String = CStr(dr(0)("txtWorksiteJobTitle"))
            MsgBox("| s = " & s & "|")
            Return s

When I run the app this is the sequence of MessageBoxes I get:
Cell 2 = 1172681
|s = food assistant|
Cell 4 = 'food assistant'
Cell 2 = 1248538
|s = Custodian|
Cell 4 = 'Custodian'
Cell 2 = 1279545
|s = Clerical Assistant|
Cell 4 = 'Clerical Assistant'
Cell 2 = 1248538

|s = Custodian|
Cell 4 = 'Custodian'
Cell 2 = 1253177
|s = Teacher Assistant|
Cell 4 = 'Teacher Assistant'
Cell 2 = 1253177
|s = Teacher Assistant|
Cell 4 = 'Teacher Assistant'
Cell 2 = 999999999
Cell 4 = "

Then the app window comes up.
Then I select a kid and select a Job Title by clicking on a row in each of the DataGridViews and I click the "Update Data" button (btnUpdatePosition_Click)

Then the following MessageBoxes pop up:
Cell 2 = 1293928
|s = Clerical|
Cell 4 = 'Clerical'

at which point the Job Title column (4) in the ApplicantsDataGridView is populated with the text "Clerical".

David








 

by: megninPosted on 2007-04-23 at 13:12:05ID: 18961181

... when the app starts up column(4) is still empty.  All the other columns are populated with correct data.

 

by: megninPosted on 2007-04-23 at 14:06:56ID: 18961501



From the btnUpdatePosition_Click Button:
        'get the job title for this applicant
        Dim dgvr As DataGridViewRow = ApplicantsDataGridView.CurrentRow
        fillInTitle(dgvr)

From the Form1_Load:
        'get the job titles for the applicants
        For Each dgvr As DataGridViewRow In ApplicantsDataGridView.Rows
            fillInTitle(dgvr)

It seems as though the Button is working but this code in the Form1_Load is not.
Is that an accurate observation?   No, I'm getting all the message boxes on form load so fillInTitle(dgvr) is firing "For Each dgvr As DGVR in ....Rows"
Sorry, I was thinking out loud.  

David

 

by: SanclerPosted on 2007-04-23 at 15:20:55ID: 18961970

David

In your form load sub, please move this line, presently at the bottom

        TabControl1.SelectedIndex = 1

to between these two lines

        txtTotalApplicants.Text = String.Format("{0} Applicants", count)

and

        'bind the applicants table to the datagridview
        ApplicantsDataGridView.DataSource = dtApplicants

So it looks like this

        txtTotalApplicants.Text = String.Format("{0} Applicants", count)

        TabControl1.SelectedIndex = 1

        'bind the applicants table to the datagridview
        ApplicantsDataGridView.DataSource = dtApplicants

It it works, and I think it will, I'll explain what's been happening.

Roger

 

by: SanclerPosted on 2007-04-23 at 15:21:32ID: 18961974

For "explain", read "attempt to explain" ;-)

Roger

 

by: megninPosted on 2007-04-24 at 06:21:33ID: 18965456

Oh, cr@p.  Let me guess?  The wrong tab had focus?   The first Tab has no DataGridview and, in fact, is not even functionally used in this app currently.  We aren' t switching to the relevant tab until after all the attempts to populate the DGVs.
I didn't even think that being an issue.

David

 

by: megninPosted on 2007-04-24 at 06:38:30ID: 18965615

Looking back on this, there were several points where I wanted to start a new form from scratch and just have one form for simplicity, no tabs or MultiView controls as I had tried during one of my earlier attempts at this app.

I made the adjustment and it works perfectly.  ... well I still have a few message boxes that I need to remove, but when I started the app all the data fields were populated.  It was a beautiful thing.

I'm going to try to clean the code up a bit (hopefully without breaking it).

How can I give you 50,000 point?

David

 

by: megninPosted on 2007-04-24 at 07:56:48ID: 18966291

Many people have contributed to this and I appreciate each and every one.  It was a tremendous learning experience for me.

Roger, I can't thank you enough.  I feel like you went WAY above and beyond in your efforts to help me with this.

It really it working great now.  I've still got some clean up to do then add the rest of the column fields that I need to show so the guy using the tool can make the kids-to-jobs matching up he has to do now for 700 kids and 100 disabled kids in our Summer Youth Employment Program.

Thank!

David

 

by: SanclerPosted on 2007-04-24 at 08:49:04ID: 18966813

David

I see I have no need to explain.  "The wrong tab had focus" indeed.

With hindsight, the answer was always there in your code.  But hindsight only comes later.  We would have got to it, in any event, a lot quicker if the debugging results that you posted - this lot

>>
When I run the app this is the sequence of MessageBoxes I get:
Cell 2 = 1172681
|s = food assistant|
Cell 4 = 'food assistant'
...
<<

- had been available in some form earlier.  It was only once it was confirmed that the right data was getting to the DGV that I went back to look at display issues.

Can I suggest that you raise another question?  There appears to me to be something wrong with how your system is handling debug reporting and checking the status of variables.  As I've said above, I just don't understand it so I won't be able to contribute to any such question that you do raise but, if you do raise one, I will be interested in any comments you get.  Debugging (as amply illustrated by this thread) is such a vital tool that I think it would be something worth you sorting out.

Thanks for the points and the kind words.

Roger  

 

by: SanclerPosted on 2007-04-27 at 07:07:19ID: 18989077

David

On the debugging issue - and I should have thought of this before, but it has only just clicked with me in the light of another question that had has been posted - I reckon you were trying to debug a Release build of your project, not a Debug build.  I've just set Build to Release on the test program I was using for this thread and get the same results as you were reporting: no debug printout in any window and the s not showing in the Autos window.

So have a look at this thread

   http://www.experts-exchange.com/Microsoft/Development/.NET/Visual_CSharp/Q_22537691.html

As I type this, that thread has not been finalised, but it's the issue you need to address.

Roger

 

by: megninPosted on 2007-04-27 at 16:22:08ID: 18992750

Oh, Thank you, Roger.

That's something I hadn't thought of.

Thank you so much for keeping me in mind and sending me this.

I wish I could send you some of my wife's freshly baked chocolate chip & walnut cookies.  ;-)

David

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...