internal static DbParameter NewPar(string Nome, object Valore, DbType tipo) { DbParameter o = null; switch (DataBaseAttuale) { case DataBase.Access: o = new System.Data.OleDb.OleDbParameter(Nome, tipo); break; case DataBase.SQLite: if (tipo == DbType.Date || tipo == DbType.DateTime) { //"YYYY-MM-DD HH:MM:SS.SSS" Valore = ((DateTime)Valore).ToString("yyyy-MM-dd HH:mm:ss.fff"); tipo = DbType.String; } //o = new System.Data.SQLite.SQLiteParameter(Nome, tipo); break; case DataBase.FireBird: o = new FirebirdSql.Data.FirebirdClient.FbParameter(Nome, tipo); break; default: throw new NotImplementedException(); } o.Value = Valore; return(o); }
internal static DbParameter NewPar(string Nome, object Valore, ParameterDirection direction = ParameterDirection.Input) { DbParameter o = null; if (direction == ParameterDirection.Output) { switch (DataBaseAttuale) { case DataBase.Access: o = new System.Data.OleDb.OleDbParameter(Nome, DbType.Int32); break; case DataBase.SQLite: o = null; //new System.Data.SQLite.SQLiteParameter(Nome, DbType.Int32); break; case DataBase.FireBird: o = new FirebirdSql.Data.FirebirdClient.FbParameter(Nome, DbType.Int32); break; default: throw new NotImplementedException(); } } else { if (Valore is DateTime) { switch (DataBaseAttuale) { case DataBase.Access: o = new System.Data.OleDb.OleDbParameter(Nome, DbType.DateTime); break; case DataBase.SQLite: Valore = cGB.DateToSQLite((DateTime)Valore); //Valore = ((DateTime)Valore).ToString("yyyy-MM-dd HH:mm:ss.fff"); o = null; //new System.Data.SQLite.SQLiteParameter(Nome, DbType.String); break; case DataBase.FireBird: o = new FirebirdSql.Data.FirebirdClient.FbParameter(Nome, DbType.DateTime); break; default: throw new NotImplementedException(); } o.Value = Valore; } else { switch (DataBaseAttuale) { case DataBase.Access: o = new System.Data.OleDb.OleDbParameter(Nome, Valore); break; case DataBase.SQLite: o = null; //new System.Data.SQLite.SQLiteParameter(Nome, Valore); break; case DataBase.FireBird: o = new FirebirdSql.Data.FirebirdClient.FbParameter(Nome, Valore); break; default: throw new NotImplementedException(); } } } o.Direction = direction; return(o); }