2
I’m running the Executesqlcommand.
In the right way, parameter doesn’t work:
var SQL = "update POSTOFFICE set Status = 1 where name = '@url'";
dbMailEnable.Database.ExecuteSqlCommand(SQL, new SqlParameter("@url", EP.Cliente.Url.Trim().ToLower()));
Parameter-less works!
var SQL = "update POSTOFFICE set Status = 1 where name = '" + EP.Cliente.Url.Trim().ToLower() + "'";
dbMailEnable.Database.ExecuteSqlCommand(SQL);
But without parameter is not recommended, SQL Injection, etc. alias in Visual Studio help nor it was possible.
What to do?
NOTE: I’m having to use this command because the database is of third party and has no primary key so I could not do via Model.
try to do
var param = EP.Cliente.Url.Trim().ToLower(); dbMailEnable.Database.ExecuteSqlCommand(SQL, new SqlParameter("@url",param);
– Marco Souza
I can direct a second response using the
Database
and not theConnection
, but I need details of the error.– Leonel Sanches da Silva