RE: custom insert for databound datagridview



I downloaded that sample. I then had to download the WM6 SDK and install it
to look at the sample. I have been planing on doing that anyway.

After looking at the sample this doesn't really answer my question. It is
pretty cool the way they implemented the triggers and all. I am use something
like that.

In the sample they use list views and manually propulate them with data.
This type of thing I already know how to do. I could easily write my own
class to do something like the triggers and all. That still would not answer
my question.

My question is if I use the built in DataGridView and similar "auto
generated" controls, forms and datasets, how do I hook into when SQL
statements get run?

When you use the auto generated stuff you never really have a chance to get
those notifications as far as I can tell. This is what I need to know about.


"ErikEJ" wrote:

have a look at Windows Mobile LOB 2008 sample, which implements managed
triggers against a SQL Compact database.

http://www.microsoft.com/downloads/details.aspx?FamilyId=428E4C3D-64AD-4A3D-85D2-E711ABC87F04&displaylang=en

--
Erik Ejlskov Jensen - MCTS: Mobile App Dev


"apitman" wrote:

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?
.



Relevant Pages

  • Re: custom insert for databound datagridview
    ... There probably is a way to insert your own change tracking logic, but I think using Sync Services, which already provides change tracking logic inside the SQL Compact engine might be easier in the long run. ... Here's a sample for syncing with an Oracle database using a custom ... I am syncing between a PDA SQLCE ...
    (microsoft.public.sqlserver.ce)
  • Re: custom insert for databound datagridview
    ... soon as syncing supports SQLCE without having to have SQL Server and IIS I ... install SQL Server and IIS just to sync. ... The method I have taken is that I will use RAPI to copy the mobile database ...
    (microsoft.public.sqlserver.ce)
  • RE: Push Method - overwriting data
    ... If you are deleting records at the SqlCe Database, ... SQL Server and inserting the new records. ...
    (microsoft.public.sqlserver.ce)
  • Reconciler Problem
    ... PocketPC device and a SQL 2K database on a desktop. ... I'm trying to get some SQLCE data into the SQL ... If I use the default conflict resolver setting ...
    (microsoft.public.sqlserver.replication)
  • Re: custom insert for databound datagridview
    ... gets put into the database until you hit the save button on the navigation ... Is there a way to get at the actual point where SQL statements are being ... Since you're talking about DataGridView, I assume you want to track the ... and a desktop SQLCE database. ...
    (microsoft.public.sqlserver.ce)

Loading