473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB.NET SQL Date Range Help

40
I know this is very simple but I cant get the syntax down...
What I'm trying to do is connect to my sql database and pull up a record from a date range that the user puts in...But I just cant get the syntax down...here is my code help will be great.
Expand|Select|Wrap|Line Numbers
  1.    Public frmDate As String
  2.     Public toDate As String
  3.  
  4. Private Sub frmWeResults_Load
  5. 'My problem is here - 
  6. Dim cmd1 As New SqlCommand("Select * from TABLE where TABLE_DATE in" + frmDate + "to" + toDate +, cnn1)
Sep 20 '07 #1
2 1263
Plater
7,872 Expert 4TB
Try this?
Expand|Select|Wrap|Line Numbers
  1. Public frmDate As String
  2. Public toDate As String
  3.  
  4. Private Sub frmWeResults_Load
  5. 'My problem is here - 
  6. Dim cmd1 As New SqlCommand("Select * from TABLE where TABLE_DATE >=' " & frmDate & "' AND TABLE_DATE <=' " & toDate &"' ", cnn1)
  7.  

Actually your IN ___ to ___ might work if you change the + to an & since that's what VB.NET uses to concatinate strings.
Sep 20 '07 #2
KA NMC
40
Thanks - that was a friggen pain...its always the simple things that get ya....



Try this?
Expand|Select|Wrap|Line Numbers
  1. Public frmDate As String
  2. Public toDate As String
  3.  
  4. Private Sub frmWeResults_Load
  5. 'My problem is here - 
  6. Dim cmd1 As New SqlCommand("Select * from TABLE where TABLE_DATE >=' " & frmDate & "' AND TABLE_DATE <=' " & toDate &"' ", cnn1)
  7.  

Actually your IN ___ to ___ might work if you change the + to an & since that's what VB.NET uses to concatinate strings.
Sep 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Mark | last post by:
Hi I have been trying to convert the week number to a range of dates that I can use. It should be fairly simple for you guru's out there but for us mere mortals it is beyond our grasp. I know...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
3
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
6
by: alexanderpope11 | last post by:
Hello, how do I write this SQL: I would like to check the Main table for invalid rows. An invalid row is: any row where the Start_date to stop_date range overlaps an invalid date in the Code...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
67
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 ...
2
by: sixdeuce62 | last post by:
Hello, I am trying to create a query that will prompt me to enter the parameter value if beginning date and ending date. I have created everything I need in the query, but I have to manually go...
4
by: davide507 | last post by:
Hello, I've created a select query with a date range parameter as well as a text field parameter Between and The second parameter: Like or Like Is Null. When you run the query, and...
2
by: grego9 | last post by:
I have a problem in Excel 2000. I have written some VBA code that transfers data from the current excel workbook to a file called "Deal Input2.xls". Everything transfers ok apart from the date in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.