Custom SQL Query

P

Prakash

I am using C# aspx page in Frontpage 2003, trying to query the records
according to current date using Custom SQL runat=server ie.
SELECT * FROM Results WHERE (Date=::lblDate::)
but it is not fetching any records even if there is date matched on database.
It works if i used
SELECT * FROM Results WHERE (Date='13/01/2006')
lblDate is an asp Label running at server and forms are running on server
too. why is the variable or object lblDate is not available on sql. what do i
need to do? please help. and date is text type on database.
Thanks in advance.
 
M

MD Websunlimited

Hi Prakash,

I'm assume you're using a asp server control <asp:label ID="myDate" />

There are no default values under ASPX to get value of the label you have to specify the TEXT property, e.g.
mySQL = "SELECT * FROM results WHERE date = '" + myDate.Text + "';"

You can may then utilize the SQL statement in ADO.net datareader or other data aware control.
 
J

Jon Spivey

Hi,
Why not just stick the current date in the sql statement and converting date
to convert the current date in to dd/mm/yyyy format, eg
SELECT * FROM Table WHERE [Date] = convert(char(10), getdate(),103)
this will pull up all records with todays date.
 
Top