vb.net - Syntax error with Date in sql query -
In my program, I change the date to date from the date of the date in the global variable Never create your query in this way Always and without exception, use parameters This SQL-Injection Avoids both methods and ensures proper formatting of your parameters. VB Sorry to know about Net, but it should be like this: Explanation: Create your query again by using My.Settings.date = DtpDate_do saving. Value.Date . I am using this date to compare date from my database but I am always getting a syntax error, irrespective of which I am changing. This is my query:
cmd.CommandText = "SELECT ID, order_date command from WHERE order_date =" & amp; My.Settings.date & amp; "Order by ID DESC"
The dates of my database are stored in dots in EU format - 17.2.2014 . Someone can provide me some help.
cmd CommandText = "SELECT ID, order_date order by WHERE order_date = @DATE ORDER ID DESC" cmd.Parameters. AddWithValue ("@ Date", My.Settings.data)
@ParamName as a placeholder for your parameter Transfer your criteria with the values Make sure either apply a concrete typed value (i.e. no object) or / And otherwise supply the data type.
Comments
Post a Comment