Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2008, 03:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Select Statement

I am encountering an error message on my select statement below.

mySQL = "SELECT TOP 78 FROM dbo.Work_History_1 WHERE Member_id = " & rsMember_Custom!Member_ID & " AND Pay_Date <= " & txtEndDate.Text & " ORDER BY Work_01 DESC,Pay_Date;"

The error message I am getting is

[Microsoft][ODBC driver for Oracle][ORA-00923; FROM keyword not found where expected.

What am I missing in my select statement

Thanks

 
Old August 19th, 2008, 03:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

The fields are missing.

SELECT TOP 78 ?????? FROM etc....

unless * it's not mandatory in oracle..

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old August 19th, 2008, 04:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi gbianchi,

After researching some more. I found out that in Oracle, you do not use "TOP", instead use "ROWNUM".

Here is the select statement:

mySQL = "SELECT * FROM dbo.Work_History_1 WHERE Member_id = " & rsMember_Custom!Member_ID & " AND Pay_Date <= '" & txtEndDate.Text & "' AND ROWNUM <= 78 ORDER BY Work_01 DESC,Pay_Date"

After running it. I found out that there is a date converssion error when comparing two dates.

How do I compare two dates in a Select statement?

Thanks


 
Old August 19th, 2008, 04:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I think that in oracle Dates should be between ''. Anyway, conversion and functions should be better.

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old August 20th, 2008, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

How does one code the select statement with the proper syntax for date comparrison.

If function or converssion is better to handle the select statement, then how do I code it?

Thanks

 
Old August 20th, 2008, 10:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

I kept playing with the code and I was able to make it work. I had to convert txtEndDate.Text.

txtEndDate = Format(txtEnddate, "dd-mmm-yyyy")

 
Old August 20th, 2008, 03:39 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Oracle has a conversion function for converting strings to dates.
It takes at least two argument, the string, and a string of characters showing where in the 1st argument the month part is, the year part, etc.

Though your solution clearly is working for you, it is weak (meaning it could easily be broken, and is not as explicit as it could be).

If you use Oracles conversion function, and you pass an impossible date, it will generate an error (which is the behavior you want).
 
Old August 20th, 2008, 04:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

I understand that there is a better way to handle the conversion but I kept searching for it and I am not having any luck.

I am aware that it can easily be broken which is why I had the user click on a date in the calendar and not let the user key in the date into the text box.

If you have any suggestions on how to code the conversion I will appreciate it. So far I have seen the TO-DATE.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
select statement ??? RinoDM SQL Server 2000 7 June 19th, 2008 08:40 AM
select Statement gregalb SQL Server 2000 3 January 15th, 2008 12:00 AM
select statement help... RinoDM SQL Server 2000 13 January 10th, 2008 08:34 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Select Statement jmss66 Oracle 1 May 27th, 2004 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.