• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Get Child project

Okay, again I have copied the code from the book, identically, but the project fails to run.  Now the 'additions' (adapters, etc) are all 'mine'.  I tried to duplicate what the code called for - I guess I 'missed'.

The only 'modification' that I made to the "complete" code, was to add this section - cause without it, how's it gonna populate the combo box?

         With cboJobs
                .DataSource = DsJobNames1
                .DisplayMember = "job_desc"
                .ValueMember = "job_id"
                .SelectedIndex = -1
            End With

But when it gets to the ValueMember, I get:

"Could not bind to the new display member"

So, I'm sure it's something I've overlooked...but what?

https://filedb.experts-exchange.com/incoming/ee-stuff/117-GetChild.zip
0
sirbounty
Asked:
sirbounty
  • 6
  • 4
1 Solution
 
SanclerCommented:
Try this

        With cboJobs
            .DataSource = DsJobNames1.jobs '<<< CHANGED HERE
            .DisplayMember = "job_desc"
            .ValueMember = "job_id"
            .SelectedIndex = -1
        End With

The .DataSource has to be a DataTable, not a DataSet

Roger
0
 
SanclerCommented:
And, having now tried to run your project, I can tell you you're going to have other problems.

You have three strongly typed datasets: dsEmployeeJobs, dsEmployeeJobs1, and dsJobNames.  

One of them - dsEmployeeJobs1 - is reporting an error

>>
dsEmployeeJobs1.xsd(1): Custom tool error: Unable to convert input xml file content to a DataSet. Parent Columns and Child Columns don't have type-matching columns.
<<

but, so far as I can see, your project makes no use of that.  Although a dataset your project is using is called "DsEmployeeJobs1", rather than "dsEmployeeJobs", what your project uses is an INSTANCE of the CLASS that is represented by the strongly typed dataset's .xsd file.  In this instance your INSTANCE is called "DsEmployeeJobs1" but it is an instance of the CLASS "dsEmployeeJobs".  See these lines

    Friend WithEvents DsEmployeeJobs1 As Jobs_and_Employees.dsEmployeeJobs

and

        Me.DsEmployeeJobs1 = New Jobs_and_Employees.dsEmployeeJobs

So that means that the datarelationship - "jobsemployee" - on which this line (in your cboJobs_SelectedIndexChanged) relies

                drsEmployee = drJob.GetChildRows("jobsemployee")

doesn't exist in anything that your project can see.  So - I haven't delved any further for now - that means you will either have to base your INSTANCE of your dataset on the "DsEmployeeJobs1" CLASS, rather than the "DsEmployeeJobs" class as it is at the moment.  Or you will have to add the relationship you want to the "DsEmployeeJobs" .xsd file.  

Whichever approach you adopt you will need to correct (or avoid repeating) the problem that DsEmployeeJobs1.xsd is reporting.  The error is because, in setting the relationship in that, you have tried to tie job_id in the employee table to job_id in the jobs table.  But in the former its datatype is Short whereas in the latter it is Integer.  I think it is actually Long in both cases in the pubs.mdb.  But I don't think that matters.  Provided the .xsd shows the same datatype - Short or Integer for the relevant field in both cases - it should work.

Roger
0
 
sirbountyAuthor Commented:
Hmm - should I start from scratch?  I'm not sure why I ended up with two of those.
There's also a "GetParent" project just before this one.  I 'may' try that one too...if I don't eventually get the hang of this.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
SanclerCommented:
>>
Hmm - should I start from scratch?
<<

I don't see why.  So far as I can tell, if you make the changes discussed above, it should work.

Roger
0
 
sirbountyAuthor Commented:
>>I don't see why.<<

This one has just been very frustrating for me...

I changed the cbo properties.
I created the relationship in DsEmployeeJobs
Commented out:
'    Friend WithEvents DsEmployeeJobs1 As Jobs_and_Employees.dsEmployeeJobs
'    Me.DsEmployeeJobs1 = New Jobs_and_Employees.dsEmployeeJobs

I still get the error on the relationship, so I delved into the xml (where I suppose you were finding these types were different).

I see
<xs:element name="job_id" msdata:AutoIncrement="true" type="xs:int" />
for jobs, and
<xs:element name="job_id" type="xs:short" minOccurs="0" />
for employees
though changing this long or integer produces the same error.

I just feel like this one is a bit beyond my skillset.  I'm going to reread the chapter in hopes of picking up something I missed, though this appears to be another one of the books infamous "we'd show you how this new application is implemented, but we didn't budget for the extra page needed, nor the additional ink"...
0
 
sirbountyAuthor Commented:
Well, I went into pubs.mdb and you were right - one was integer, one was long.
So, I adjusted it there - but it didn't do much for the program.  So, I modified the xml so that both have
<xs:element name="job_id" type="xs:long" minOccurs="0" />

I know that's probably not "right" - but I think this is another stupid mistake in either the book code or the backend database.  Either way upsets me - this book wasn't cheap...

So, the code is running now in one example, I'm going to try it in this one again and see...
0
 
sirbountyAuthor Commented:
<sigh>
I got further, but now I'm getting my favorite "object not set to instance of an object" error on

     CType(Me.DsEmployeeJobs1, System.ComponentModel.ISupportInitialize).BeginInit()

Should that simply be commented out?
0
 
SanclerCommented:
It's up to you.  But if you start from the project as you last uploaded it here, the only steps you need to take are.

Open it.

Double-click on dsEmployeeJobs1.xsd in the Solution Explorer window.  Make sure the DataSet view rather than the XML view is showing.  In the pane for the jobs table click on the job_id element and change, in the dropdown, its datatype to Short.  Save that .xsd file, and close the window for it.

Double-click on Form1.vb in the Solution Explorer window.  Make sure the code view rather than design view is showing.  Open the Windows Generated Code Region and change

    Friend WithEvents DsEmployeeJobs1 As Jobs_and_Employees.dsEmployeeJobs

to

    Friend WithEvents DsEmployeeJobs1 As Jobs_and_Employees.dsEmployeeJobs1 '<<< NOTE THE ADDED 1

and

        Me.DsEmployeeJobs1 = New Jobs_and_Employees.dsEmployeeJobs

to

        Me.DsEmployeeJobs1 = New Jobs_and_Employees.dsEmployeeJobs1 '<<< NOTE THE ADDED 1

Then, still in Form1 code view, add this code

        With cboJobs
            .DataSource = DsJobNames1.jobs '<<< CHANGED HERE
            .DisplayMember = "job_desc"
            .ValueMember = "job_id"
            .SelectedIndex = -1
        End With

just before

            mblnInitialized = True

in the form load sub.

And then start the project.  I've just done that and (with one additional alteration - changing the location of the pubs.mdb - which you needn't make) it worked for me.

Roger

PS  I was typing and trying the above out while you did your last two posts.  But I thnk it's all still relevant.
0
 
sirbountyAuthor Commented:
I tried closing it, but it didn't prompt me to 'not' save, so I downloaded it again.  Trying this out now (didn't realize you could change the type right there... : \
0
 
sirbountyAuthor Commented:
You are truly a master. :^)
Thanx Roger, once again.

So, this would probably just be a bogus setup on the database that caused all this headache (other than the conundrum with the dataset(s)).

I've got another question pending, to hopefully fill in some gaps that the book leaves out, if you're interested in another 500...nobody seems interested yet. (http:/Q_21861138.html)

Many, many thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now