Attaixneima
New Member
Hi, got this Google Map example from this site: http://www.4guysfromrolla.com/articles/052610-1.aspx.
Working great but want to see if can get working with executing a sql server stored procedure rather than a select command. Am confused as to where the 2 parameters are being loaded from and if there is a way to pass them to SQL. Here is the modifed version which goes against our sql server and works fine but want to do a little bit sql code which needs to be in sql so we can bring back more fields but not sure how to change to selectcommand work with executing an stored procedure and not sure where the @Latitude and @Longitude parameters are getting loaded?
<asp:Content runat="server" ID="headContent" ContentPlaceHolderID="head">
<script type="text/javascript" src=http://aspmessageboard.com/archive/index.php/"http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src=http://aspmessageboard.com/archive/index.php/"Scripts/GoogleMapHelpers.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>Store Locations Near <asp:Label ID="lblAddress" runat="server"></asp:Label></h2>
<p>
<a href=http://aspmessageboard.com/archive/index.php/"FindAStore.aspx"><< Enter a new search...</a>
</p>
<div id="map_canvas" style="width:400px;height:275px"></div>
<div style="width: 800px">
<asp:ListView ID="lvSearchResults" runat="server"
DataSourceID="dsSearchResults" style="margin-right: 6px; width: 800px">
<EmptyDataTemplate>
<div id="noResults">
<p>
There are no stores within 15 miles of the address you entered. Please try
again...
</p>
<p>
<b style="color: #FF0000">The address you entered is not known or understood.
Try simplifying the address, or enter just a city, state or zip code...</b>
</p>
</div>
</EmptyDataTemplate>
<LayoutTemplate>
<table cellspacing="0" cellpadding="0" rules="all" class="searchResults" width="800">
<tr>
<th>
<asp:LinkButton runat="server" ID="lbSortStoreNumber" CommandName="Sort" CommandArgument="StoreNumber">Store #</asp:LinkButton>
</th>
<th>
<asp:LinkButton runat="server" ID="lbSortDistance" CommandName="Sort" CommandArgument="DistanceFromAddress">Distance</asp:LinkButton>
</th>
<th>Address</th>
</tr>
<asplaceHolder runat="server" ID="itemPlaceholder"></asplaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("StoreNumber") %></td>
<td><%# Eval("DistanceFromAddress", "{0:0.00}")%> miles</td>
<td>
<table>
<tr>
<td>
<asp:Image runat="server" ID="imgIcon"
ImageUrl='<%# string.Format("~/Images1/NumberToImageHandler.ashx?number={0}", Container.DisplayIndex + 1) %>' />
</td>
<td>
<%# Eval("Address")%>, <%# Eval("City")%>, <%# Eval("Region")%> <%# Eval("PostalCode")%>
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</div>
<asp:SqlDataSource ID="dsSearchResults" runat="server"
ConnectionString="<%$ ConnectionStringsroduction2ConnectionString2 %>"
***Would like to make to execute stored procedure***
SelectCommand="SELECT PC_CUST_NUM AS StoreNumber, PC_CUST_ADDR AS Address, PC_CUST_CITY AS City, PC_CUST_STATE AS Region, 'US' AS CountryCode, PC_CUST_ZIP AS PostalCode, PC_CUST_LATITUDE AS Latitude, PC_CUST_LONGITUED AS Longitude, SQRT(POWER(PC_CUST_LATITUDE - @Latitude, 2) + POWER(PC_CUST_LONGITUED - @Longitude, 2)) * 62.1371192 AS DistanceFromAddress FROM tblCustomerFile WHERE (ABS(PC_CUST_LATITUDE - @Latitude) < 0.25) AND (ABS(PC_CUST_LONGITUED - @Longitude) < 0.25)">
<SelectParameters>
<asparameter Name="Latitude" />
<asparameter Name="Longitude" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
Thanks, JoeOf course, 10 minutes after postiing, I think I got it. I was manually changing code but was doing wrong so reconfigured datasource through design view and was able to get going in case it helps anyone else.
<asp:SqlDataSource ID="dsSearchResults" runat="server"
ConnectionString="<%$ ConnectionStringsroduction2ConnectionString2 %>"
SelectCommand="spJJStoreLocations"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asparameter Name="Latitude" />
<asparameter Name="Longitude" />
</SelectParameters>
</asp:SqlDataSource>
Working great but want to see if can get working with executing a sql server stored procedure rather than a select command. Am confused as to where the 2 parameters are being loaded from and if there is a way to pass them to SQL. Here is the modifed version which goes against our sql server and works fine but want to do a little bit sql code which needs to be in sql so we can bring back more fields but not sure how to change to selectcommand work with executing an stored procedure and not sure where the @Latitude and @Longitude parameters are getting loaded?
<asp:Content runat="server" ID="headContent" ContentPlaceHolderID="head">
<script type="text/javascript" src=http://aspmessageboard.com/archive/index.php/"http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src=http://aspmessageboard.com/archive/index.php/"Scripts/GoogleMapHelpers.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>Store Locations Near <asp:Label ID="lblAddress" runat="server"></asp:Label></h2>
<p>
<a href=http://aspmessageboard.com/archive/index.php/"FindAStore.aspx"><< Enter a new search...</a>
</p>
<div id="map_canvas" style="width:400px;height:275px"></div>
<div style="width: 800px">
<asp:ListView ID="lvSearchResults" runat="server"
DataSourceID="dsSearchResults" style="margin-right: 6px; width: 800px">
<EmptyDataTemplate>
<div id="noResults">
<p>
There are no stores within 15 miles of the address you entered. Please try
again...
</p>
<p>
<b style="color: #FF0000">The address you entered is not known or understood.
Try simplifying the address, or enter just a city, state or zip code...</b>
</p>
</div>
</EmptyDataTemplate>
<LayoutTemplate>
<table cellspacing="0" cellpadding="0" rules="all" class="searchResults" width="800">
<tr>
<th>
<asp:LinkButton runat="server" ID="lbSortStoreNumber" CommandName="Sort" CommandArgument="StoreNumber">Store #</asp:LinkButton>
</th>
<th>
<asp:LinkButton runat="server" ID="lbSortDistance" CommandName="Sort" CommandArgument="DistanceFromAddress">Distance</asp:LinkButton>
</th>
<th>Address</th>
</tr>
<asplaceHolder runat="server" ID="itemPlaceholder"></asplaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("StoreNumber") %></td>
<td><%# Eval("DistanceFromAddress", "{0:0.00}")%> miles</td>
<td>
<table>
<tr>
<td>
<asp:Image runat="server" ID="imgIcon"
ImageUrl='<%# string.Format("~/Images1/NumberToImageHandler.ashx?number={0}", Container.DisplayIndex + 1) %>' />
</td>
<td>
<%# Eval("Address")%>, <%# Eval("City")%>, <%# Eval("Region")%> <%# Eval("PostalCode")%>
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</div>
<asp:SqlDataSource ID="dsSearchResults" runat="server"
ConnectionString="<%$ ConnectionStringsroduction2ConnectionString2 %>"
***Would like to make to execute stored procedure***
SelectCommand="SELECT PC_CUST_NUM AS StoreNumber, PC_CUST_ADDR AS Address, PC_CUST_CITY AS City, PC_CUST_STATE AS Region, 'US' AS CountryCode, PC_CUST_ZIP AS PostalCode, PC_CUST_LATITUDE AS Latitude, PC_CUST_LONGITUED AS Longitude, SQRT(POWER(PC_CUST_LATITUDE - @Latitude, 2) + POWER(PC_CUST_LONGITUED - @Longitude, 2)) * 62.1371192 AS DistanceFromAddress FROM tblCustomerFile WHERE (ABS(PC_CUST_LATITUDE - @Latitude) < 0.25) AND (ABS(PC_CUST_LONGITUED - @Longitude) < 0.25)">
<SelectParameters>
<asparameter Name="Latitude" />
<asparameter Name="Longitude" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
Thanks, JoeOf course, 10 minutes after postiing, I think I got it. I was manually changing code but was doing wrong so reconfigured datasource through design view and was able to get going in case it helps anyone else.
<asp:SqlDataSource ID="dsSearchResults" runat="server"
ConnectionString="<%$ ConnectionStringsroduction2ConnectionString2 %>"
SelectCommand="spJJStoreLocations"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asparameter Name="Latitude" />
<asparameter Name="Longitude" />
</SelectParameters>
</asp:SqlDataSource>