I'm working with SQL Server Compact Edition. I try to delete data from the database on max date, I try on query it works perfectly, but when I execute in my program, turn to delete all data not base on query I have created.
Here is my code
string sqlCom="";
sqlCom = " delete from " + tableName; ;
sqlCom += " where messageid not in(";
sqlCom += " select messageid from tabmessageinclient";
sqlCom += " where convert(nvarchar(10),dtmessagetime,101) ";
sqlCom += " in (select max(convert(nvarchar(10),dtmessagetime,101)) from tabmessageinclient ))";
SqlCeConnection ceCon = new SqlCeConnection(Properties.Settings.Default.MyConnection);
if (ceCon.State == System.Data.ConnectionState.Open)
{ ceCon.Close(); }
ceCon.Open();
SqlCeCommand cmd = new SqlCeCommand();
cmd.Connection = ceCon;
cmd.CommandText = sqlCom;
cmd.ExecuteNonQuery();
does anyone know what wrong with my code, sorry for bad english