Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have this statement

 

SELECT * FROM vwAllMatrixVehicles WHERE created >= '2007/8/9'

 

Using query analyser in sql management studio it returns about 80 rows.

 

Trying to use it in ASP.NET with the SqlCommand class the same statement returns 0 rows.

 

I've double checked my code, its fine. If I replace the select statement with something else that doesn't use a date its fine.

 

Does SqlClient handle dates differently somehow?

 

Thanks

  • Administrators
Posted

It's probably down to the date format being interpreted differently between ASP.Net and SQL Management studio.

 

Try putting the month as a full string (i.e. either August or September depending) and see if that alters the results. Also how is the string being generated in the ASP.Net page?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Originally I was just building the string with concatenation, but for this example I just put it directly into a string

 

Dim sql as string = "SELECT * FROM vwAllMatrixVehicles WHERE created >= '2007/8/9'"

 

Its very puzzling???

Posted

Spot on. If I reverse the month and day it works fine. SqlClient must split the string up and pass the values individually, perhaps as parameters.

 

Thanks a lot

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...