Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 15th, 2004, 04:10 PM
jean-louis jean-louis is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 jean-louis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sql query with visual basic

i have a problem with sql query with this code

dim Onedate as date
Onedate = dateadd("m" , -1 ,date)

adoSale.recordsource = "select * from tblSale where fldDate > " & OneDate
adoSale.refresh
dgdgrid1.refresh

the problem that give me all the records. it's like i don't put a WHERE clause
the data base is access 2000 and i work with visual basic 6.0
i got only a problem with query including a date

thank for helping me

jean-louis

Reply With Quote
  #2  
Old December 15th, 2004, 04:31 PM
A2k's Avatar
A2k A2k is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 166 A2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 44 m 10 sec
Reputation Power: 4
Ok, You almost had it with the dateadd function you used in your VB code.

In sql server you should be unsing DateDiff(<timescale>, olddate, newdate) > 20 replace 20 with however days/months/years you wish to see.

hope that helps

Reply With Quote
  #3  
Old December 15th, 2004, 07:34 PM
jean-louis jean-louis is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 jean-louis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by A2k
Ok, You almost had it with the dateadd function you used in your VB code.

In sql server you should be unsing DateDiff(<timescale>, olddate, newdate) > 20 replace 20 with however days/months/years you wish to see.

hope that helps

thanks for the answer but i use access 2000 not sql server.

I think the problem is in the query.

Jean-louis

Reply With Quote
  #4  
Old December 15th, 2004, 10:29 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
Try

adoSale.recordsource = "select * from tblSale where fldDate > #" & OneDate & "#"
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #5  
Old December 16th, 2004, 07:26 PM
jean-louis jean-louis is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 jean-louis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
Try

adoSale.recordsource = "select * from tblSale where fldDate > #" & OneDate & "#"

thank you Doug i think you give me the half of the solution

because this code work

adoSale.recordsource = "select * from tblSale where fldDate > #05-24-04#"

but the problem with my OneDate it contains 24-05-04 the day before the month
maybe it is the problem but i don't know how too fix it

thanks again for the hint use ##

jean-louis

Reply With Quote
  #6  
Old December 17th, 2004, 09:07 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 4
If the date format doesn't match, it's the control panel - regional options- date configuration, just change it the to desired format.

Reply With Quote
  #7  
Old December 17th, 2004, 10:27 AM
A2k's Avatar
A2k A2k is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 166 A2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 44 m 10 sec
Reputation Power: 4
try just passing the date accross as a string.

Code:
adoSale.recordsource = "select * from tblSale where fldDate > '" & OneDate & "'"


This usually works for me.

I however would do this:

Code:
adoSale.recordsource = "select * from tblSale where datediff(d, fldDate, " & OneDate & ")>0"

Reply With Quote
  #8  
Old December 30th, 2004, 04:12 AM
spida spida is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 spida User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Try dis

Try dis...

dim Onedate as date
Onedate = dateadd("m" , -1 ,date)

adoSale.recordsource = "select * from tblSale where fldDate > #" & OneDate & "#"

let me know if dat works...am sorry cant chk at dis mo coz am at wrk

Quote:
Originally Posted by jean-louis
i have a problem with sql query with this code

dim Onedate as date
Onedate = dateadd("m" , -1 ,date)

adoSale.recordsource = "select * from tblSale where fldDate > " & OneDate
adoSale.refresh
dgdgrid1.refresh

the problem that give me all the records. it's like i don't put a WHERE clause
the data base is access 2000 and i work with visual basic 6.0
i got only a problem with query including a date

thank for helping me

jean-louis

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > sql query with visual basic


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway