none
Generating Variables in SQL statement using AS RRS feed

  • Question

  • I am trying to generate a variable as part of a SQL statement using the AS feature.  For Example:

    SELECT lat, lon, (expression) AS distance FROM base. 

    I want to be able to perform a computation (compute the distance between two geographic points).  The table base contains lat and lon for a number of points of interest.  I have available the user's Lat and Lon as determined by a geolocation call (using javascript and passed to the ASP page.

    I can access the users Lat and Lon in part of my custom SQL statement (developed in the dialog box in Expression 4) and  it looks like this

    WHERE [lat] > @lat

    The WHERE statements effectively restrict the range of records returned, so I am confident that the user location information was actually passed to the server.

    When I try to use the same logic (eg @lat) as part of my computation of miles, the SQL query does not work.  When I try to define the user location as a session parameter (MyLat), Expression tells me that asp:sessionparameter is not valid. 

    How should I express the user location (lat and lon) so that they can be included in the computation of distance in the SELECT statement?

    Wednesday, March 20, 2013 9:07 PM

Answers

  • Your question is not about Expression Web, but about SQL and asp.net.  (It doesn't matter that you are using EW for this.)

    Please try the asp.net forum http://forums.asp.net/ , or, for specific questions about what queries and what syntax is understood by the database you are using, a forum for that database.

    The asp.net forum won't care if you used EW.  They will care what your full, relevant code looks like in the page, so do post that, not just snippets in a discussion.

    • Marked as answer by RG46873 Wednesday, March 20, 2013 11:18 PM
    Wednesday, March 20, 2013 9:41 PM