Click here to Skip to main content
15,850,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i have written query which works properly in access.

OdbcCommand command = new OdbcCommand("SELECT * FROM [SlideShowTable1] where (startddate <= ?) AND (endddate >=?) ORDER BY rnd (INT(NOW*ImageID)-NOW*ImageID)", con);
            command.Parameters.AddWithValue("sdate", System.DateTime.Now.ToString("M/d/yyyy"));
            command.Parameters.AddWithValue("edate", System.DateTime.Now.ToString("M/d/yyyy"));

but when i tried to execute sqme query in sql server then its not working ..

SqlCommand command = new SqlCommand("SELECT * FROM [SlideShowTable1] where (startddate <= @sdate) AND (endddate >=@edate)ORDER BY rnd (INT(NOW*ImageID)-NOW*ImageID)  ", con);
            command.Parameters.AddWithValue("@sdate", System.DateTime.Now.ToString("M/d/yyyy"));
            command.Parameters.AddWithValue("@edate", System.DateTime.Now.ToString("M/d/yyyy"));
John-ph 30-Aug-13 4:19am    
what is the error message?
Anurag Sinha V 30-Aug-13 4:20am    
Error message plz...
phil.o 30-Aug-13 5:37am    
As a general rule, please avoid textspeak on this forum :)
Anurag Sinha V 30-Aug-13 7:07am    
Roger that Mr. Phil.
[no name] 30-Aug-13 5:47am    
"its not working" is not at all a helpful description of any kind of a problem. Do you call your mechanic on the phone and tell him "car broke" and expect he would know what you are talking about?

1 solution

First You should run query in Sql server and then add back to C# in order to execute command
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900