Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a program that asks the user for a date and then returns a recordset of Orders that have an order date greater than or equal to the date entered.

 

In the SQL Startement I have 'WHERE OrderDate >= ' & UserDate, this does not work .

 

Can anyone tell me what the SQL statement should be.

 

Thanks

Posted

Sorry, a bit more info would be a good idea as 'this does not work' doesn't really say much.

 

To start I am still using ADO 2.7 as not had time to fully learn ADO.NET yet, I also use the Microsoft Masked Edit Control to ask for the dates.

 

I have an access database with orders in it for this year, and I build the SQL statement my self.

 

The Code looks like this

 

sSQL = "SELECT * FROM POPHeader WHERE POPOrdDate >= " & me.mebStartDate.CtlText & " ORDER BY POPOrdNo"

 

this gives me

 

'SELECT * FROM POPHeader WHERE POPOrdDate >= 31/01/2003 ORDER BY POPOrdNo'

 

What I get returned are all the orders in the file, when I started to write this I was asking for a Start & End date that looked like this

 

sSQL = "SELECT * FROM POPHeader WHERE POPOrdDate >= " & me.mebStartDate.CtlText & " AND POPOrdDate <= " & me.mebEndDate.CtlText & " ORDER BY POPOrdNo"

 

This gives me

 

'SELECT * FROM POPHeader WHERE POPOrdDate >= 01/01/2003 AND POPOrdate <= 31/01/2003 ORDER BY POPOrdNo'

 

If I put single quotes in I get the following error

 

An unhandled exception of type 'System.Exception' occurred in microsoft.visualbasic.dll

 

Additional information: Data type mismatch in criteria expression.

 

Any Help would be appreciated

Thanks

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...