setfocus
asked on
DateTime With C# and MS SQL
Hello,
I seem to be missing something from this code, it always generates an incorrect syntax error.. how do I cast a C# DateTime to a MSSQL DateTime?
Thanks for you time
I seem to be missing something from this code, it always generates an incorrect syntax error.. how do I cast a C# DateTime to a MSSQL DateTime?
Thanks for you time
DateTime dateTime = new DateTime(2006, 09, 07, 22, 21, 44);
SqlCommand myCommand = new SqlCommand("SELECT * FROM Mytable1 WHERE MyDateAndTime = " + dateTime, myConnection);
mySqlDataReader = myCommand.ExecuteReader();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I too agree with above suggestions, why do you want to invite hackers and SQL Injection? use parameter saw above.....
ASKER
That's Excellent! Thanks very much for your time...
NP. Glad to help :)