G
Guest
(Portions previously posted in SQL Server CE newsgroup, but it appears no one
is minding the shop over there!)
Ok, so I managed to get merge replication working and I have a single table
in a database out on my PDA. I now want to change a row in the table and
synch back to the main database. I'm trying to do the easy part – use
System.Data.SqlServerCe to update the table in SQL CE but I can't get the
blasted table to update! (I know this because I examine the results in the
Query Analyzer after running my app.)
In addition, on the PDA…
- I know I’m connecting to the database from my application code because I
can select and read labels from the table with no problems.
- I know the update statement is correct because I can run it from the Query
Analyzer (both against the backend database and the CE database) and achieve
the desired result.
Earl, from the SQL Server CE newsgroup writes that he “too had some SQLCE
update problems that were not code related at all, rather the issue was with
the backend database structureâ€. Can anyone expand on this? The table that
I’m experimenting with does have a trigger on the backend database but it
doesn’t affect the column that I’m attempting to update, and besides, I don’t
think triggers are replicated hence it seems unlikely that they would foul
things up until you attempt to synch back up with the backend.
Here is my code, if it is run on the PDA against the replicated CE database,
no exceptions are thrown, and no rows are updated. Have I goofed up somehow?
Bill
try
{
SqlCeConnection cn = new SqlCeConnection( @"Data Source=\My
Documents\oxsite.sdf" );
string str = "UPDATE cioxsitelist SET oxsitelabel = 'Kilroy was here'
WHERE oxsitecode = 66";
SqlCeCommand cmd = new SqlCeCommand( str, cn );
cmd.CommandType = CommandType.Text;
cn.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
catch( SqlCeException sex )
{
foreach( SqlCeError err in sex.Errors )
{
MessageBox.Show( err.Message, "SQL CE Error" );
}
}
catch( Exception ex )
{
MessageBox.Show( ex.Message, "Error" );
}
is minding the shop over there!)
Ok, so I managed to get merge replication working and I have a single table
in a database out on my PDA. I now want to change a row in the table and
synch back to the main database. I'm trying to do the easy part – use
System.Data.SqlServerCe to update the table in SQL CE but I can't get the
blasted table to update! (I know this because I examine the results in the
Query Analyzer after running my app.)
In addition, on the PDA…
- I know I’m connecting to the database from my application code because I
can select and read labels from the table with no problems.
- I know the update statement is correct because I can run it from the Query
Analyzer (both against the backend database and the CE database) and achieve
the desired result.
Earl, from the SQL Server CE newsgroup writes that he “too had some SQLCE
update problems that were not code related at all, rather the issue was with
the backend database structureâ€. Can anyone expand on this? The table that
I’m experimenting with does have a trigger on the backend database but it
doesn’t affect the column that I’m attempting to update, and besides, I don’t
think triggers are replicated hence it seems unlikely that they would foul
things up until you attempt to synch back up with the backend.
Here is my code, if it is run on the PDA against the replicated CE database,
no exceptions are thrown, and no rows are updated. Have I goofed up somehow?
Bill
try
{
SqlCeConnection cn = new SqlCeConnection( @"Data Source=\My
Documents\oxsite.sdf" );
string str = "UPDATE cioxsitelist SET oxsitelabel = 'Kilroy was here'
WHERE oxsitecode = 66";
SqlCeCommand cmd = new SqlCeCommand( str, cn );
cmd.CommandType = CommandType.Text;
cn.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
catch( SqlCeException sex )
{
foreach( SqlCeError err in sex.Errors )
{
MessageBox.Show( err.Message, "SQL CE Error" );
}
}
catch( Exception ex )
{
MessageBox.Show( ex.Message, "Error" );
}