public static SQLiteConnection mymdbConn = new SQLiteConnection("Data Source = :memory:");
public static String mFilename = "Q:\\cap\\Candle.db3";//Data Source=
public static void Mdb()
{
mymdbConn.Open();
if (mFilename != null)
{
Devart.Data.SQLite.SQLiteCommand cmd = new Devart.Data.SQLite.SQLiteCommand(@"ATTACH " + mFilename + " AS disk") { Connection = mymdbConn }; //, myQConn;
try
{//Note:verify query
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
Debug.WriteLine(string.Format("exception{0}", e));
}
cmd = new SQLiteCommand("CREATE TABLE NIFTYNBNM AS SELECT * FROM disk.MAIN.NIFTYNBNM;", mymdbConn);
try
{//Note:verify query
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
Debug.WriteLine(string.Format("exception{0}", e));
}
}
/*.SQLiteConnection.
_sqlConn = new SQLiteConnection("Data Source=:memory:");
_sqlConn.Open();
SQLiteCommand cmd = new SQLiteCommand(@"ATTACH " + sldbFilename + " AS disk", _sqlConn);
cmd.ExecuteNonQuery();
cmd = new SQLiteCommand("CREATE TABLE SampleInfo AS SELECT * FROM disk.SampleInfo;", _sqlConn);
cmd.ExecuteNonQuery();
cmd = new SQLiteCommand("CREATE TABLE Results AS SELECT * FROM disk.Results;", _sqlConn);
cmd.ExecuteNonQuery();
cmd = new SQLiteCommand("DETACH disk", _sqlConn);
cmd.ExecuteNonQuery();
*/
/* if (mymdbConn.State != 0)
{ //Console.WriteLine("true State:{0} ", myConn.State);
}
else
{ //Console.WriteLine("false State:{0} ", myConn.State);
mymdbConn.Open();
}
// String myIQ =String.Format("INSERT INTO MAIN.CDBM ([DT],[PIDS],[M])values({0},{1},{2})",":DT", 7119, 1 );
myIQ = String.Format("INSERT INTO [main].[NIFTYNB](Time,Rate,OI,Qty,PID,BQ,SQ,TBQty,TSQty,BQty,BRate,AQty,ARate,pRate,pQty,pTime,pBQty,pBRate,pAQty,pARate,pTBQty,pTSQty,pOI,CUMC,UMC) Values('{0:G}',{1:F},{2},{3},{4},{5},{6},{7},{8},{9},{10:F},{11},{12:F},{13:F},{14},'{15:G}',{16},{17:F},{18},{19:F},{20},{21},{22},'{23}','{24}')", ":DT", LP, toi, LQ, PIDS, BQ, SQ, ttbq, ttsq, tbq, tbp, toq, top, tpltp, tpltq, ":DT", tpbq, tpbp, tpoq, tpop, tptbq, tptsq, tpoi, parts[20], parts[21]); // pTime,pBQty,pBRate,pAQty,pARate,pTBQty,pTSQty,pOI,CUMC,UMC
// Debug.WriteLine(String.Format("{0}", myIQ));
sqminsert(myIQ, LTD);*/
}
public static void sqminsert(String myIQ, DateTime dt)
{//Note what can be done for date
// String myIQ =String.Format("INSERT INTO MAIN.CDBM ([DT],[PIDS],[M])values({0},{1},{2})",":DT", 7119, 1 );
SQLiteCommand sqCommand = new SQLiteCommand(myIQ) { Connection = mymdbConn };
sqCommand.Parameters.Add("DT", dt);
// SQLiteCommand sqCommand = new SQLiteCommand(myIQ) { Connection = mymdbConn };
if (mymdbConn.State != 0)
{ //Console.WriteLine("true State:{0} ", myConn.State);
}
else
{ //Console.WriteLine("false State:{0} ", myConn.State);
// mymdbConn.Open();
}
{
try
{//Note:verify query
sqCommand.ExecuteNonQuery();
// int r = Console.WriteLine(r + " rows affected.");
}
catch (Exception e)
{
Debug.WriteLine(string.Format("exception{0}", e));
}
}
{
// mymdbConn.Close();
}
}
public static void cmdb()
{
Devart.Data.SQLite.SQLiteCommand cmd = new SQLiteCommand("DETACH disk", mymdbConn);
cmd.ExecuteNonQuery();
}