Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
memento
Starting Member
16 Posts |
Posted - 2006-05-31 : 05:20:04
|
Hi,I have a page with a calendar and a datasource that selects * from a table, whose dtDateofActivity is a DateTime.I am following this tutorial: [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/VWD_SSE_App.asp[/url]When you click on a date there is a filter on the table to show results from that specific date. Following the tutorial what I did was: quote: Let's now tie in the Calendar control to filter the activities based on the dates. To achieve this, go the FilterParameters collection property in the Property window and click the "..." button. When the Parameter Collection Editor pops up, click the Add Parameter button. Rename the parameter to dtDateOfActivity, set the parameter source to Control, from the ControlID drop down menu select calActivity, and leave the default value blank. Click the OK button to close the editor. Next, in the FilterExpression field, enter dtDateOfActivity='@dtDateOfActivity'. Configure the odsActivitiesUnpublished data source in the exact same manner, except set the bIsPublished parameter's default value to False.
So I have<asp:SqlDataSource ID="SqlDataSource1" Runat="server" ConnectionString="<%$ ConnectionStrings:testandoConnectionString %>" SelectCommand="SELECT * FROM [tblActivity]" FilterExpression="dtDateOfActivity='@dtDateOfActivity'" OnSelecting="SqlDataSource1_Selecting" EnableCaching="True"> <FilterParameters> <asp:ControlParameter Name="dtdateOfActivity" ControlID="Calendar1" PropertyName="SelectedDate" Type="DateTime" DefaultValue=""></asp:ControlParameter> </FilterParameters> </asp:SqlDataSource> The problem I get is quote: Cannot perform '=' operation on System.DateTime and System.String. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.EvaluateException: Cannot perform '=' operation on System.DateTime and System.String.
I can't seem to find any way to make it work, I've tried replacing '@dateofActivity' for @dateofActivity, #@dateofActivity#, #'@dateofActivity'#...none works.Any help greatly appreciated!The problem, as far as I can see it, is that when I pass the argument '@dateOfActivity' it interperts it as a String and I can't seem to find a way to say that it is a date, even though I have ControlID="Calendar1" PropertyName="SelectedDate" Type="DateTime"! |
|
memento
Starting Member
16 Posts |
Posted - 2006-06-01 : 05:27:44
|
I found out what the problem was. The correct code should be: FilterExpression="dtDateOfActivity=#{0}#" The {0} gets the first FilterParameter and the # says that variable is a DateTime. |
 |
|
widget2
Starting Member
2 Posts |
Posted - 2007-09-05 : 11:50:19
|
Thanks Memento. That really helped.I am working on the same articles by Dan Burman and now can not seem to get the 'Enroll' button to fire the AddEnrollment method. I am getting an error saying that the 'username' does not allow nulls:"Cannot insert the value NULL into column 'Username', table '~\APP_DATA\STUDENTACTIVITIES.MDF.dbo.tblUserActivity'; column does not allow nulls. INSERT fails.The statement has been terminated."Did you manage to get yours working. Please help.Thanks |
 |
|
widget2
Starting Member
2 Posts |
Posted - 2007-09-05 : 11:55:18
|
Thanks Memento. That really helped.I am working on the same articles by Dan Burman and now can not seem to get the 'Enroll' button to fire the AddEnrollment method. I am getting an error saying that the 'username' does not allow nulls:"Cannot insert the value NULL into column 'Username', table '~\APP_DATA\STUDENTACTIVITIES.MDF.dbo.tblUserActivity'; column does not allow nulls. INSERT fails.The statement has been terminated."Did you manage to get yours working. Please help.Thanks |
 |
|
|
|
|
|
|