Date Range help with SQL statement in VB.net

Smokeywade

Member
Joined
Sep 11, 2007
Messages
22
Programming Experience
3-5
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.
VB.NET:
 Public frmDate As String
    Public toDate As String

Private Sub frmWeResults_Load
'My problem is here - 
Dim cmd1 As New SqlCommand("Select * from TABLE where TABLE_DATE in" + frmDate + "to" + toDate +, cnn1)
 
I think I get it a little bit - thru out the rest of my app I'm basically using paramaters except for this piece...but my params are working with a Stored Procedures...

I'll try the method you provided and see if I can get it to work - thanks
 
ok, well, there's no difference, look:


Dim cmd as New OracleCommand("MY_SPROC:)START_DATE, :END_DATE)")
cmd.CommandType = StoredProcedure
cmd.Parameters.AddWithValue("START_DATE", startDateTimePicker.Value)
cmd.Parameters.AddWithValue("END_DATE", endDateTimePicker.Value)


Dim cmd as New OracleCommand("SELECT * FROM table WHERE dateCol BETWEEN :START_DATE AND :END_DATE")
cmd.CommandType = Text
cmd.Parameters.AddWithValue("START_DATE", startDateTimePicker.Value)
cmd.Parameters.AddWithValue("END_DATE", endDateTimePicker.Value)


Know what I mean?
 
I got it thanks...
I didnt realize you could do it that way without sending it to a stored procedure on the Database...I'm still a newbie learning...Thanks for all the help...
 
Back
Top