Following -
http://blogs.msdn.com/sqlservercompact/rss.xml
I thought I would build a generic Compact Framework method that would determine if we have any rows to send back to Sql Sever. This should save lots of those unnecessary sync's and hence GPRS/3G charges.
I came up with the following code snippet.
public bool AnyRowsToUpload(string tablename){StringBuilder sbsql = new StringBuilder();sbsql.Append("SELECT MAX(__sysIG),MAX(__sysCG) ");sbsql.Append("FROM ");sbsql.Append(tablename + " ");sbsql.Append("UNION ALL ");sbsql.Append("SELECT LastUploadedGen,SentGen80 ");sbsql.Append("FROM ");sbsql.Append("__sysMergeSubscriptions");
SqlCeDataReader rdr = Sql(sbsql.ToString()); // < helper function to just execute the SQL, search my blog for sourceint maxig = 0;int maxcg = 0;int lastuploadedgen = 0;int sentgen80 = 0;if (rdr != null){if (rdr.Read()){maxig = CoreDb.DbToInt(rdr[0]); // < helper function to just quickly turn reader value to int, seach my blog for sourcemaxcg = CoreDb.DbToInt(rdr[1]);rdr.Read();lastuploadedgen = CoreDb.DbToInt(rdr[0]);sentgen80 = CoreDb.DbToInt(rdr[1]);}rdr.Dispose();rdr.Close();}// for SQL Server 2005, uncomment the below return maxig > lastuploadedgen || maxcg > lastuploadedgen;// for SQL Server 2000, uncomment the below // return maxig > sentgen80 || maxcg > sentgen80;}
I'm particularly pleased with this (excuse my lack of modesty), because the whole thing is executed within a single call to SQL Compact.
Theme design by Jelle Druyts
Pick a theme: BlogXP calmBlue
My Virtual Earth Balloon Races www.racingballoon.com Richard JonesPowered By The Fridge Server