custom insert for databound datagridview
- From: apitman <apitman@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 23 Apr 2008 11:41:06 -0700
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?
.
- Follow-Ups:
- Re: custom insert for databound datagridview
- From: Ginny Caughey MVP
- RE: custom insert for databound datagridview
- From: ErikEJ
- Re: custom insert for databound datagridview
- Prev by Date: Re: Performance problem in sql ce
- Next by Date: Can't drop table because "The system timed out waiting for a locK".
- Previous by thread: VS2008 and Compact Server 3.5
- Next by thread: RE: custom insert for databound datagridview
- Index(es):
Relevant Pages
|