Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

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
Avatar of Sancler
Sancler

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
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
Avatar of sirbounty

ASKER

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.
>>
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
>>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"...
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...
<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?
ASKER CERTIFIED SOLUTION
Avatar of Sancler
Sancler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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... : \
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!