maxgall
asked on
use a string to define a sqldatasource parameter
I have created the following.
A sqldatasource using a parameter to retrieve data from the database which not older than todays date and display it in a gridview.
Below is the code :
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConn %>"
SelectCommand="SELECT * FROM [calendar] WHERE ([appDate] > @appDate)">
<SelectParameters>
<asp:SessionParameter DefaultValue="01/06/2006" Name="appDate" SessionField="isToday"
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
On the code behind file I have created a DateTime variable called isToday
Dim isToday as DateTime = date.now()
and want to use this variable as below in the sqlDataSource Parameter.
<asp:SessionParameter DefaultValue="01/06/2006" Name="appDate" SessionField="isToday"
Should this work or am I doing this all wrong. I am very new to this so I would need all the code.
thanks vm
A sqldatasource using a parameter to retrieve data from the database which not older than todays date and display it in a gridview.
Below is the code :
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConn %>"
SelectCommand="SELECT * FROM [calendar] WHERE ([appDate] > @appDate)">
<SelectParameters>
<asp:SessionParameter DefaultValue="01/06/2006" Name="appDate" SessionField="isToday"
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
On the code behind file I have created a DateTime variable called isToday
Dim isToday as DateTime = date.now()
and want to use this variable as below in the sqlDataSource Parameter.
<asp:SessionParameter DefaultValue="01/06/2006" Name="appDate" SessionField="isToday"
Should this work or am I doing this all wrong. I am very new to this so I would need all the code.
thanks vm
ASKER
This is not excactly what I am looking for.
Above I have the sqldatasource to retrieve data from my database. I now need to define a parameter to retrieve data which are
> than todays date.
In asp 1.0 I have just used a string and assigned the value calendar1.todaysdate and passed this string on to the method to retrieve my data. How can I do this now with the sqldatasource where the select command is as follows:
SelectCommand="SELECT * FROM [calendar] WHERE ([appDate] > @appDate)">
I used to be able to pass a string to the parameter @appDate.
Is there something like:
Dim myDate as String = date.now()
<asp: StringParameter Name="appDate" String="myDate"
thanks
Above I have the sqldatasource to retrieve data from my database. I now need to define a parameter to retrieve data which are
> than todays date.
In asp 1.0 I have just used a string and assigned the value calendar1.todaysdate and passed this string on to the method to retrieve my data. How can I do this now with the sqldatasource where the select command is as follows:
SelectCommand="SELECT * FROM [calendar] WHERE ([appDate] > @appDate)">
I used to be able to pass a string to the parameter @appDate.
Is there something like:
Dim myDate as String = date.now()
<asp: StringParameter Name="appDate" String="myDate"
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes thanks that is working
session("isToday") = Today