Connecting Tech Pros Worldwide Forums | Help | Site Map

How do I pass a System Date Parameter to a SQLDatasource?

Expert
 
Join Date: Jan 2008
Posts: 365
#1: Nov 1 '08
Hey Guys and Gals,

I'm a little stumped on this one. I'm trying to find out how to pass the System Date from the server to a SQLDatasource control.

I need to know the syntax for passing that either in the aspx page, or the code behind file (aspx.vb)

What I have so far is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  3.             ConnectionString="<%$ ConnectionStrings:DailyRazorDatabase %>" 
  4.             SelectCommand="SELECT [EventDate], [EventTitle], [EventStartTime], [EventEndTime], [Description] FROM [EventCalendar] WHERE ([EventDate] BETWEEN @EventDate AND @EventDate+30)">
  5.             <SelectParameters>
  6.                 <asp:ControlParameter ControlID="Calendar1" DbType="DateTime" Name="EventDate" DefaultValue=<Need Syntax Here  />
  7.             </SelectParameters>
  8.         </asp:SqlDataSource>
  9.  
  10.  
Thanks for all your help in advance.

Joe P.

Expert
 
Join Date: Jan 2008
Posts: 365
#2: Nov 2 '08

re: How do I pass a System Date Parameter to a SQLDatasource?


Hey Guys and Gals,

I was able to figure it out with some more research.

What you have to do is create a control on a form. Make it invisiable, and set the value of the control to the current date/time.

Then you can use that control to pass the value in as a parameter.

Thanks again for all your help.

Joe P.
Reply


Similar .NET Framework bytes