Trouble with bindingNavigator

Troy

Well-known member
Joined
Feb 7, 2005
Messages
153
Programming Experience
10+
I'm trying to set up my binding navigator bar to only display data pertaining to a certain ID.

VB.NET:
BindingSource1.DataSource = dsPackage
BindingSource1.DataMember = "Package"
BindingNavigator2.BindingSource = BindingSource1

Now within Package is a field name PackageID
I would like my binding Navigator to only display the information with the same PackageID.

Unfortunately all I see is a BindingSource option and I have set it to
VB.NET:
BindingNavigator2.BindingSource = BindingSource1             'see above

Is there a way to have to Binding Navigator tied to this field inside the BindingSource?

If so could you show me please?
 
I think youre confused. A BindingNavigator is a pseudo component based on a ToolStrip and several items. Its only purpose is to scroll the .Position of a BindingSource in order that different records be displayed elsewhere; it has no innate display capabilities of its own. Perhaps you can rephrase your question, possibly including a screenshot of how you would like your form to look?
 
Service.JPG


here's a picture of the Services screen. I have the bindingnavigator's binding source = BindingSource1. see previous post.

I want the navigator to only scroll through information with the same PackageID not the entire list of packages. How can I set the navigator to use the package information and only scroll through like PackageID's. Or do I have to create an entirely seperate Dataset with only the packages with the same Package ID's to be able to bind it to that?
 
I'm not quite sure where the master/detail relationship is on this screen, if it exists.. If this screen is showing a single datatable's contents then the fault could siomply be that you have written and/or called a Fill(datatable) method, whereas you should have written and called a FillByPackageID(dt, the_id) method

It's not the bindingnav's job to nav to only records matching certain criteria; it's the BindingSOurce's job to only allow certain criteria through the filter (and the the BN only moves within that filtered list).
I'm sure, however, that you can see it is foolish to download 5000 records from a database, if youre then going to run a client side filter that shows 10 of them.
You would take the step of making another query on the tableadapter (or if you will never need to download all of the rows, then modify the original tableadapter query to include the predicate. Downloading all rows from a table is a rare operation. Real world queries nearly always run with a predicate)
That query, that was:

SELECT * FROM packages

becomes:

SELECT * FROM packages WHERE packageID = :pACKAGE_ID


When loading your form:

myTableAdapter.FillByPackageID(myDataset.Packages, 10)


It only loads the packageID 10s..




The other tip i would offer, is that you put a custom format into your date time pickers so that you can make them shorter to align with the other controls :D
 
Sweet! Thats it. Thats the bit I wasn't grasping! Thanks cjard!
 
I'm not quite sure where the master/detail relationship is on this screen, if it exists.. If this screen is showing a single datatable's contents then the fault could siomply be that you have written and/or called a Fill(datatable) method, whereas you should have written and called a FillByPackageID(dt, the_id) method

It's not the bindingnav's job to nav to only records matching certain criteria; it's the BindingSOurce's job to only allow certain criteria through the filter (and the the BN only moves within that filtered list).
I'm sure, however, that you can see it is foolish to download 5000 records from a database, if youre then going to run a client side filter that shows 10 of them.
You would take the step of making another query on the tableadapter (or if you will never need to download all of the rows, then modify the original tableadapter query to include the predicate. Downloading all rows from a table is a rare operation. Real world queries nearly always run with a predicate)
That query, that was:

SELECT * FROM packages

becomes:

SELECT * FROM packages WHERE packageID = :pACKAGE_ID


When loading your form:

myTableAdapter.FillByPackageID(myDataset.Packages, 10)


It only loads the packageID 10s..




The other tip i would offer, is that you put a custom format into your date time pickers so that you can make them shorter to align with the other controls :D

:(
I'm using OLEDB, I reset the query to the following:

Dim daCustomersPackages As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM Package WHERE PackageID = ?PACKAGEID", cn)
Dim dsCustomersPackages As New System.Data.DataSet()

In my Load event for the form I have tried to fill

daCustomersPackages.FillByPackageID(dsCustomersPackages.PackageID, 10)

I tried FillByPackageID but that wasn't valid.
 
:(
I'm using OLEDB, I reset the query to the following:
Youre also using .NET 2.. you shouldnt be using data adapter at all..

Dim daCustomersPackages As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM Package WHERE PackageID = ?PACKAGEID", cn)
Access doesnt support named parameters*
Find: ?PACKAGEID
Replace: ?

For named parameters, use a real database.

*jmcilhinney might point out that it does

daCustomersPackages.FillByPackageID(dsCustomersPackages.PackageID, 10)

I tried FillByPackageID but that wasn't valid.
*sigh*

FillByPackageID WOULD BE the name of the method that the IDE WOULD create for you if you WOULD actually use the new methods of data access.
I say WOULD, because I know that you dont..

Additionally, you make a new UNTYPED generic dataset, and then expect it to contain a property called PackageID representing a typed datatable. It doesnt, again because you dont use the new methods of data access

All I can do is tell you to read the DW2 link..
 
Youre also using .NET 2.. you shouldnt be using data adapter at all..


Access doesnt support named parameters*
Find: ?PACKAGEID
Replace: ?

For named parameters, use a real database.

*jmcilhinney might point out that it does


*sigh*

FillByPackageID WOULD BE the name of the method that the IDE WOULD create for you if you WOULD actually use the new methods of data access.
I say WOULD, because I know that you dont..

Additionally, you make a new UNTYPED generic dataset, and then expect it to contain a property called PackageID representing a typed datatable. It doesnt, again because you dont use the new methods of data access

All I can do is tell you to read the DW2 link..

LOL ... I'm sensing a little bit of tension.
 
This goes back to the how can I allow them to Select seperate databases to use then?

Since this thread is using Access and Jet I thought I was posting in the proper place to discuss my Access issues. I appologize that I'm not fully understanding these new ways of using dataaccess but the last time I wrote a database application was this:

VB.NET:
Open "R",1,F$, RL
RR=0: F=NF + 1
F=F-1
For aa = 0 to 35
A$ = " "
Seek #1, AA + ((F*36) +1)
Put #1, , A$
Next AA
Close #1
F = F + 1

As you can see that quite Archaic and my Learning curve is a great deal. I do know many things but everytime I Learn say .Net then it changes.

So please understand I'm trying to grasp this but it's like teaching Plato Modern English.
 
I have no idea what that code is! Plato sure lived in a strange time... ;)

The idea behind what cjard said is that Visual Studio 2005 offers a designer tool for create custom, strongly typed datasets that will allow you to create SQL queries that are called like methods. Try addign a new item to your project and select dataset, open the file with the default editor, drag tables from the server explorer window and you'll be able to add methods to the table adapters that look just like stored procedures to your app.

I obviously won't write a complete tutorial about this in here, but tons of them exist on the web, including cjard's signature ;) . Try and google this : tutorial Dataset designer vs2005.
 
lol Yeah I've done all that what that method doesn't allow is for you to be able to load different Databases at run time to work with. It only allows for one which everything is bound too. Thats why I am using OLEDB. It's been a long discussion. But instead of someone helping with my delima I've been instructed to basically scrap the idea, rewrite the program to not do what I want it to do which is offer the user the chance to choose which Database to work with.

Let's say they create a database with content spanning 1 year of business and decide for security reasons they want to backup the database at the end of the year and use a new one. Eventually they may want to reload the old one temporarily to view the old records. Then go back to the current one to work on it again.

I have all that functionality working I'm just having a minor problem. I guess I'll work it out on my own. Although There may be an easier way to do this with and SQL Database or but draging and binding it's not the way I want to go because it's more limited.

P.S. That old code told the PC to write each character in a string onto a space on the hardrive. Old school equiv of creating a database before Access came along.

Believe it or not The program still works fine with QBasic lol
 
Back
Top