public DataTable GetDataTable(string strSQL, string TableName) { DataTable dt = null; try { using (SQLiteConnection scon = new SQLiteConnection(DataAccessUtilities.CreateSQLiteConnectionString())) { scon.Open(); SQLiteCommand com = new SQLiteCommand(strSQL, scon); using (SQLiteDataReader dr = com.ExecuteReader()) { dt = new DataTable(TableName); dt.Load(dr); dr.Close(); } com.Dispose(); scon.Close(); scon.Dispose(); } } catch (Exception ex) { LogManager.Instance.LogMessage("Error in GetDataTable", ex); } return(dt); }
public bool SyncClientDatabase() { bool ReturnStatus = true; try { UpdateEventMessage("Syncing Client and Server"); //================================================================= //Testing Code //================================================================= //if ( System.Diagnostics.Debugger.IsAttached ) // if (ClientDatabaseExist()) // return true; //================================================================= DeleteClientDatabase(); InitClientDatabase(); string sqliteConnString = DataAccessUtilities.CreateSQLiteConnectionString(); using (SQLiteConnection conn = new SQLiteConnection(sqliteConnString)) { conn.Open(); foreach (string TableName in DataAccessUtilities.SyncTableNames()) { i9Message responseMsg = i9MessageManager.SendMessage(MobileMessageType.SyncCache, SyncCacheType.GetFullTable, "SyncClientDatabase", typeof(string), TableName); if (responseMsg.ErrorStatus.IsError) { UpdateEventMessage("Error Syncing Table " + TableName + " - Error Message: " + responseMsg.ErrorStatus.ErrorMsg); ReturnStatus = false; } else { UpdateEventMessage(" " + TableName); LoadData(conn, responseMsg.MsgBodyDataSet, TableName); } } } } catch (Exception ex) { UpdateEventMessage("Error Syncing Tables - Error Message: " + ex.Message); LogManager.Instance.LogMessage("Sync method error", ex); ReturnStatus = false; } return(ReturnStatus); }