I have to download the data residing in a sqlite database in my Xamarin app into a firebirdsql database which is on my PC on the same wifi network and I reach with IP address. Everything works correctly but the unloading times are very long.
This is the connection string:
connessione = @"Server=" + ip_server + @";User=sysdba;Password=XXXXXXXX;Pooling=true;Database=" + ip_server + @":C:\FirebirdSQL\Photo.FDB";
This is the SQL statement :
string _dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), VarGlobal.dbSQLITE);
var db = new SQLiteConnection(_dbPath);
FbCommand cmdfb = new FbCommand("INSERT INTO photo (id,rifiddir,immaginebit) VALUES (@id,@rifiddir,@immaginebit)", conn);
cmdfb.Parameters.Add("@id", FbDbType.VarChar);
cmdfb.Parameters.Add("@rifiddir", FbDbType.VarChar);
cmdfb.Parameters.Add("@immaginebit", FbDbType.Binary);
conn.Open();
var tuttelefoto = db.Query<Photo>("SELECT id,rifiddir,immaginebit FROM Photo");
foreach (var singolafoto in tuttelefoto)
{
cmdfb.Parameters["@id"].Value = singolafoto.Id;
cmdfb.Parameters["@rifiddir"].Value = singolafoto.rifiddir;
cmdfb.Parameters["@immaginebit"].Value = singolafoto.immaginebit;
await cmdfb.ExecuteNonQueryAsync();
}
conn.Close();
It all works but it takes 10 seconds for each insert. I wanted to rewrite the code in just one line:
FbCommand cmdfb = new FbCommand(" INSERT INTO PHOTO " +
" SELECT '1', 'one' FROM RDB$DATABASE " + " UNION ALL SELECT '2', 'two ' FROM RDB$DATABASE " + " UNION ALL SELECT '3', 'three' FROM RDB$DATABASE " + " UNION ALL SELECT '4', 'four' FROM RDB$DATABASE ", conn);
The foto size is max 1,5 Mb
the wi-fi is 166 Mbps.
How can I insert a byte[]
field in text format? Could this solve my problems?
Many of you will tell me not to connect directly to the database but to use a web service. I know. But the app only works when the phone and PC are on the same network. Thank you