Hi folks,
I imagine I'll get the same folks answering me here, but I figured it's best to post separate questions as separate threads, so that people who search might find this helpful.
So, quick summary: I have a very simple .net app connected to an Access database. Users visit a site and are presented with a suggestion about a software program they use. They vote on the suggestion using a series of radio buttons. When they vote, their vote is written to the database, and a new suggestion is displayed.
When I write the vote data to the database, I include the user's IP address, which I grab using Request.UserHostAddress.
I've used an AccessDataSource for this select:
I want to use that WHERE clause to exclude suggestions that the current user has already voted on, based on their IP address.
As you can see, I've created a parameter for the IP address, and I want that parameter to use the Request.UserHostAddress. But, if I put that in the parameter like this, it doesn't work:
If I hard-code an IP address into the DefaultValue, it works exactly as I'd like it to.
So, my question is this: how can I get the IP parameter to use the Request.UserHostAddress, so that the SELECT statement will dynamically exclude certain suggestions based on the IP of the user?
(FWIW, I'm also aware that this solution isn't particularly graceful. Obviously, a person could vote multiple times from different computers and so forth. But, this application is very low-key and I'm not that concerned about it. A mild deterrent will serve fine!)
Thanks very much!
Steve
I imagine I'll get the same folks answering me here, but I figured it's best to post separate questions as separate threads, so that people who search might find this helpful.
So, quick summary: I have a very simple .net app connected to an Access database. Users visit a site and are presented with a suggestion about a software program they use. They vote on the suggestion using a series of radio buttons. When they vote, their vote is written to the database, and a new suggestion is displayed.
When I write the vote data to the database, I include the user's IP address, which I grab using Request.UserHostAddress.
I've used an AccessDataSource for this select:
Code:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="xxx"
SelectCommand="SELECT SuggestionID, CategoryName, Suggestion, Suggester, URL FROM SuggestionSelector WHERE (SuggestionID NOT IN (SELECT SuggestionID FROM Votes WHERE (IP = ?)))">
<SelectParameters>
<asp:Parameter DefaultValue="help me!" Name="IP" />
</SelectParameters>
</asp:AccessDataSource>
I want to use that WHERE clause to exclude suggestions that the current user has already voted on, based on their IP address.
As you can see, I've created a parameter for the IP address, and I want that parameter to use the Request.UserHostAddress. But, if I put that in the parameter like this, it doesn't work:
Code:
<asp:Parameter DefaultValue="Request.UserHostAddress" Name="IP" />
If I hard-code an IP address into the DefaultValue, it works exactly as I'd like it to.
So, my question is this: how can I get the IP parameter to use the Request.UserHostAddress, so that the SELECT statement will dynamically exclude certain suggestions based on the IP of the user?
(FWIW, I'm also aware that this solution isn't particularly graceful. Obviously, a person could vote multiple times from different computers and so forth. But, this application is very low-key and I'm not that concerned about it. A mild deterrent will serve fine!)
Thanks very much!
Steve