I notice that the SQL default values are not being picked up by the dataset - I have to manually make a change to each row with a default value in each DataTable in the DataSet.
Indeed, because the DataTable schema is inferred from the SELECT query, not from any table definition (the select query can contain the results of functions or operations on fields so getting the tabledef wont help), and the only thing it really looks at is the primary key, whether you have selected all the columns of it and hence how to write the Ins Upd and Del queries for DML
It would be a neat addition to include defualt values but:
a) youd have to get MS to upgrade the dataset generator
b) if you want to use default values you would normally jsut pass NULL to the database.. so leaving the datset's default value of NULL would cause a NULL to be inserted, a default vlaue to be used, and the DAL automatically requiereis the database after the insert to check for values calculated by the db.. sooo, though the user wouldnt se ethe defult value before they saved, they would see it after.
REmember, datasets are not intended to replace databases and will not replicate all their fnctionality. You can, however, write some code if you want that will pyull a tabledef and turn it into XML that the dataset generator works off.. I do this often, with an app I wrote to turn fixed width data into XML compatible with a dataset. It also generates the full XML definition of the dataset, so all i do is describe my FWidth file, my app makes the dataset and the regular expresisons needed to transform the data and all i do is make a new dataset, then open it with XML Editor rather than DataSet Designer, paste the XML def in and voila.. the dataset suddenly becomes fully populated with all the tables that will be parsed out of the FW file.
The upshot is you can write a prog that parses the xml of the dataset, looks up the default and writes new XML back..
If you think it will be quicker than setting it manually or leaving it null, that is..
I also had to change the DataGrid's EditMode to 'EditOnEnter' to get a good mouse click behaviour
I dont quite know what a BAD mouse behaviour would be but I do have a hack I apply to some of my DataGridViews where a context menu exists.. On CellMouseDown, if the cell is within the currently selected range, do nothing, otherwise, set the current cell = to the cell that was mousedowned.. THis ensures a selcetion can be made, pointed to, right clicked etc.. but if the user just points to a cell they want to interact with, they dont have to left click it first before right clicking to operate on it.. Much more intuitive relative to windows de facto HCI (select 10 files, then right click a different one, 10 selections disappear and newly ricghtclicked file is selected and operated on)
I also added:
TableAdapter.Update(Dataset)
Dataset.AcceptChanges()
to the RowEnter of the DataGrid
(above is abbreviated)
Yeah, um.. I really wouldnt do that. You dont want to fire off an update query every time the user mouses around the grid. Why did you do that?
Also, -1 (<0) are OK for the primary key, it means Autonumber passthrough to the sql database.
Yes but see earlier point about requerying db.. the idea for local relationships is that you will use some field to maintain the relation but it will be updated on save. The relationship is preserved.
Note: I wanted the data to update to sql sooner than later for other uses to see it.
Well, ok.. but i find the optimistic concurrency model quite effective.. I operate in a financial processing company with a lot of customer service activity and its rare that their opreations overlap to the point where we need data to be updated to the earliest opportunity
I will go with this model for now, It might do for the complete app. and if not, I may have a better idea of what I want down the track.
No worries, Its what I did too.. staritng out, it's a bit awkward but it soon makes sense and is very well thought out for the most part