Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Have I accidentally created multiple currency managers?
 

Have I accidentally created multiple currency managers?

Hi All,

Ref: VS 2003

I have a two datetimepickers which show the arrival and departure date. I also have two navigation buttons to go through the different arrival and departure dates in the dataset. There is also a lable that show the current position of the total number of dates. That all works fine. I get the problem when I call addNew. The label shows the total increase by one but the current position doesnt move and I therefore cant add the new dates. The last point to be aware of is the binding of the datetimepickers is through a datarelation (if that makes any difference).

I believe somehow I have created multiple currency managers, but I wouldn't know where to start in order to find out.

Please help!!!!!!

CodeScribler  Monday, May 23, 2005 6:08 PM

I'm not clear on the scenario so I'm not positive I understand what's going on.  Here's part of what I think you're doing - please confirm:

   You have a Flight table (or similar) with Arrival and Departure dates
   The Arrival and Departure dates are bound to DateTimePickers
   You click AddNew to create a new Flight
   This doesn't go to the AddNew row

I'm missing how the Departure and Arrival dates in the DataSet relate to the above however my first guess is that when you call AddNew, you're not setting initial values for the Arrival and Departure dates in your data model (they are DBNull.Value).  When the binding tries to bind these values to the DateTimePicker, it fails because the DateTimePicker doesn't directly support DBNull.Value (or null).  When binding fails, it tries to find a row that doesn't fail and puts you on the first row.  You could verify this by changing your DateTimePickers to ReadOnly TextBoxes and see if it behaves closer to what's expected.

Joe

Joe Stegman  Monday, May 23, 2005 6:56 PM

I'm not clear on the scenario so I'm not positive I understand what's going on.  Here's part of what I think you're doing - please confirm:

   You have a Flight table (or similar) with Arrival and Departure dates
   The Arrival and Departure dates are bound to DateTimePickers
   You click AddNew to create a new Flight
   This doesn't go to the AddNew row

I'm missing how the Departure and Arrival dates in the DataSet relate to the above however my first guess is that when you call AddNew, you're not setting initial values for the Arrival and Departure dates in your data model (they are DBNull.Value).  When the binding tries to bind these values to the DateTimePicker, it fails because the DateTimePicker doesn't directly support DBNull.Value (or null).  When binding fails, it tries to find a row that doesn't fail and puts you on the first row.  You could verify this by changing your DateTimePickers to ReadOnly TextBoxes and see if it behaves closer to what's expected.

Joe

Joe Stegman  Monday, May 23, 2005 6:56 PM

It appears you are trying to do something similar to one of the 101 Samples for VS 2003, specifically the "How To - Data Binding with Navigation."  You can use this for a reference, in any event.

If you modify this to add an Add New button, you will encounter a similar error: some of the values are null and the record cannot be added.  What you will want to do is add a record via the underlying dataset, not the BindingContext, e.g.,


    Private Sub AddNewRecord()
        'Dim prod As ProductDataSet.ProductsRow = productInfo.Products.NewProductsRow()
        productInfo.Products.AddProductsRow("New product", 1, 1, "20", Decimal.Parse("12.34"), 2, 5, 6, False, "Supplier X", "Category Y")
        LastRecord()

    End Sub


 



durstin  Tuesday, May 24, 2005 12:01 AM

You can use google to search for other answers

Custom Search

More Threads

• Duplicate Designer.vb file when saving dataset
• PropertyGrid - how to hide icon with folder which is on the top of property window (beside icon to sorting AZ)?
• Using BindingNavigator with multiple BindingSources
• DataGridView - Put an icon at header cell
• sorting datagrid view on update
• Filtering data in a Column - vb.net & Sql SP
• Execute another form's Sub from a Dialog
• Problem on moving file from One directory to another direcytory --- The process cannot access the file because it is being use
• Using encrypted connection string from unmanaged code
• How to convert code using DataGrid to use DataGridView instead?