HI WELCOME TO SIRIS

Blue Prism Interview Questions With Answers

Leave a Comment



accepted
The best approach is to start using prepared, parameterized queries. They ensure that comparisons are done correctly, and they prevent the possibility of SQL injection attacks.
Your code would be rewritten like this:
string txt = "select count(*) from cont where Data_deschiderii < @compareDate;"; 
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand(txt, conn);
cmd.Parameters.Add("@compareDate", SqlDbType.Date);
cmd.Parameters["@compareDate"].Value = TextBox1.Text;
int x = Convert.ToInt32(cmd.ExecuteScalar().ToString());
Response.Write(x);
That is, I am assuming that your database field Data_deschiderii is of a date form of datatype.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.