views:

346

answers:

1

Here is my scenario:

  1. User enters in address
  2. Address is geolocated
  3. Geolocation is buffered (1 ft)
  4. Graphic returned is used in query feature to get a road ID

All the above is pretty straight forward ESRI JavaScript API – now I am hitting a bit of a crossroads in approaches and I am wondering if you have an approach you use for the following:

I have the road segment ID in a variable on the client side in JavaScript. I need this ID to query a database table in sql server.

The query is pretty simple

SELECT Library FROM DataTable WHERE Road_ID = x

It is just a database table not geodatabase. The returned data will only be one record and one attribute - the closest Library. I will use the returned data to continue on in the JavaScript API.

So I have an idea of how to proceed but I am not sure it is the smartest way to go. My tool set is ASP.NET, C#, Dojo, ESRI JavaScript API and JavaScript:

  1. Connection string to the database goes in web.config
  2. JavaScript will have to interact with C# function
  3. C# function should be on the “code behind page” of an aspx page.
  4. I think I need to implement a Client Callback without Post Backs as outlined in this article http://msdn.microsoft.com/en-us/library/ms178208.aspx
  5. Then I can use the callback data returned to move on my happy way with the JavaScript API on the client side again.
+1  A: 

I think you're making things way too complicated with Client Callback.

Create an Web Handler that returns the record as JSON or XML and make the road ID a querystring parameter of the Handler.

Call the handler via an AJAX call from within your JavaScript.

CptSkippy