Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Peace be Upon You
I am Developing a VB.Net 2010 Software in which i have an SQl Database in which each row (Record) has a Date Field , i want to view all the records for which the date lies between two dates which the user determines using two DateTimePickers , my SQl Query is the following:-

SQL
SELECT        *
FROM            Datalog
WHERE         Date BETWEEN DateTimePicker1.Value And DateTimepicker2.Value


the problem is that when executing this SQL Query an arror message "the multipart identifier DateTimePicker1 Could not be bound " , i want to know why i'm getting this message?
Actually My Deadline is after a week from today 15 Apr 2014, i hope to find an answer ASAP!!
Posted
Updated 15-Apr-14 11:22am
v3
Comments
Richard C Bishop 15-Apr-14 16:03pm    
Show all of the code you are using for that function.

1 solution

VB
DIM Query as String = String.Format("Select * from Datalog where [Date] Between {0} and {1}", DateTimePicker1.Value, DateTimePicker2.Value)


and then run the query against your database.
DateTimePicker2 is not an SQL syntax but .NET
 
Share this answer
 
Comments
Bilal Altyb 19-Apr-14 5:38am    
just how can i run the query against your database? i tried
Dim DGV As New SqlClient.SqlCommand("Select * from Datalog where DateRx Between DateTimePicker1.Value AND DateTimePicker2.Value", DatalogTableAdapter.Connection)
DataGridView1.DataSource = DGV.ExecuteReader
will it work or i have to do something else??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900