Re: custom insert for databound datagridview
- From: "Ginny Caughey MVP" <ginny.caughey.online@xxxxxxxxxxxxxx>
- Date: Thu, 24 Apr 2008 12:54:53 -0400
You might look at the current changed event handler for the binding source that is bound to the DataGridView. I'm curious what you want to do with the changed data after you know what it is. For example would Sync Services for ADO.NET (which is designed for change tracking and updating) be a solution for you?
Ginny
"apitman" <apitman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:950A7F41-3D68-405C-9D54-9E051593E9F7@xxxxxxxxxxxxxxxx
I don't know if this is the right forum to post this in, but I will start
here....
I am writing a desktop database application. I created a simple SQL CE
database. I then created a new form and dragged the DataGridView control from
the toolbox to the form.
I then created a new data source and pointed it to my desktop SQLCE database.
I then dragged that data source onto the DataGridView.
At this point I have a running application that can insert record into the
database.
Now comes the fun part. The first field is a Guid. I have read many things
about the pros and cons of using Guids, but in my case I have decided I want
to use them as I will be sharing data among several devices eventually.
I made the ID column not visible and then, of course, started getting errors
when I created a new row because the Guid was null.
If fixed this by creating my own class that derived from the DataGridView
and override the OnRowValidating. I did this because that is where I was
getting the error. I then put in custom logic to check and see if the row
guid is blank and if it is I create a new guid.
This all works. I tell you about it in case there is a better way and it
relates to my second question:
I now want to keep track of changes in the database. I created a second
table in the database that will contain the Guid of the record that was added
/ changed / deleted and the date / time it happened. I will use this to track
changes.
The problem is that I need to have a place somewhere that I do the insert /
update of this meta data table when something changes in the main table.
SQLCE doesn't support triggers, so that won't work. The benefits of SQLCE
outweight this, however, and I am hoping there is a solution.
So the question is in a data bound situation where can I hook into when the
SQL statements get run? I put break points all over inside my data source
class that got created and they never get called. I tried places like the
Insert method and Update method. I can only assume those functions are for if
I want to call them in my code, but the data bound stuff doesn't call them.
SQLCE also doesn't support multiple statements in a single call so I can't
just modify the INSERT INTO statement and put another after it.
Ideas?
--
Ginny Caughey
Device Application Development MVP
www.wasteworks.com
Software for Waste Management
.
- Follow-Ups:
- Re: custom insert for databound datagridview
- From: apitman
- Re: custom insert for databound datagridview
- References:
- custom insert for databound datagridview
- From: apitman
- custom insert for databound datagridview
- Prev by Date: RE: custom insert for databound datagridview
- Next by Date: Re: custom insert for databound datagridview
- Previous by thread: RE: custom insert for databound datagridview
- Next by thread: Re: custom insert for databound datagridview
- Index(es):
Relevant Pages
|
Loading