?
Solved

Get Child project

Posted on 2006-05-23
10
Medium Priority
?
260 Views
Last Modified: 2016-08-29
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
Comment
Question by:sirbounty
  • 6
  • 4
10 Comments
 
LVL 34

Expert Comment

by:Sancler
ID: 16749274
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
 
LVL 34

Expert Comment

by:Sancler
ID: 16749510
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
 
LVL 67

Author Comment

by:sirbounty
ID: 16750074
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Sancler
ID: 16750366
>>
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
 
LVL 67

Author Comment

by:sirbounty
ID: 16750997
>>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
 
LVL 67

Author Comment

by:sirbounty
ID: 16751327
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
 
LVL 67

Author Comment

by:sirbounty
ID: 16751345
<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
 
LVL 34

Accepted Solution

by:
Sancler earned 2000 total points
ID: 16751418
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
 
LVL 67

Author Comment

by:sirbounty
ID: 16751505
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
 
LVL 67

Author Comment

by:sirbounty
ID: 16751558
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question