Link to home
Start Free TrialLog in
Avatar of WestcountryBusiness
WestcountryBusiness

asked on

Windows CE 5.0 - Can I edit a datagrid or bind text fields to a dataset?

I've been developing a stock control system using VS2003 & MS SQL  2005.  Now I need to add the option to use Bar Code scanners.

The Bar Code Scanners are Windows CE5.0 devices with inbuilt wireless networking.  I have upgraded to VS2005 for this project as I understand its better suited to this task, so am also getting used to new environment.

I can build & deploy an app that reads direct from the MS SQL DB.  I've not installed SQL CE as I seem to be able to access the DB direct.  I can fill a datagrid with the contents of a table, so that's all fine.

I want to be able to update the DB.  The datagrid is editable, which I believe is the case - is that correct.  I have added Text Boxes to the form, but there does appear to be a datasource option.

Problem is, I'm just not sure I'm approaching this correctly.  Should I be installing SQL CE?  Is there an updatable datagrid option?  

I will be working in an environment where the wireless link may fail occassionally and so would like to store updates locally if no connection & then update in batch when I can get a connection.  That sounds to me like writing to a local dataset & then performing an update() as & when.  I guess I could create a form that adds / amends rows in the dataset & configure a data adapter to update the dataset - but is that the best approach.

I'm likely to be spending a lot of time in the near future on this project - so just after a 'heads up' really.  Am I on the right lines?  Any tips / advise greatly received.

Jon
Avatar of WestcountryBusiness
WestcountryBusiness

ASKER

After a little more testing, I've found I'm able to fill a dataset - so retrieving live data from the SQL server and use datagrid (or other controls) to view this and select a record.

I can create a form using Text Fields to display / edit data.  This aren't bound to the dataset but this can be done manually:

eg: Assuming I have a combobox with a data source of the Addresses table in my dataset and I just want to select an account from the drop down & then display / update the Full Name field.  If the Full Name is changed, then I press the Save button to save to dataset: (dataset is filled on load)

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        fld_FullName.Text = MyDataSet.Addresses.Item(ComboBox1.SelectedIndex).Item("Full_Name")
End Sub

Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
        MyDataSet.Addresses.Item(ComboBox1.SelectedIndex).Item("Full_Name") = fld_FullName.Text
End Sub

I can then use the dataadapter Update to write the changes to the dataset back to the SQL DB.  I can see this would work & isn't too much work to do (after all, its a windows CE device - the screens only big enough to display a handful of fields anyway!).

So, unless I hear otherwise, that's the approach I'll take.  However, I'd still be happy to hear from anyone who could either suggest a better way - or maybe just confirm that this is the right way.
ASKER CERTIFIED SOLUTION
Avatar of EE_AutoDeleter
EE_AutoDeleter

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