如何通过javascript从sql server获取表格数据
这是我的场景:
- 用户输入地址
- 地址已地理
- 定位 地理位置已缓冲(1 英尺)
- 返回的图形用于查询 获取道路 ID 的功能
上述所有内容都非常简单 ESRI JavaScript API – 现在我遇到了一些方法的十字路口,我想知道您是否有用于以下目的的方法:
我有路段 ID JavaScript 中客户端的变量。 我需要这个 ID 来查询 sql server 中的数据库表。
查询非常简单
SELECT 库 来自数据表 WHERE Road_ID = x
这只是一个数据库表而不是地理数据库。 返回的数据只会是一条记录和一个属性——最近的图书馆。 我将使用返回的数据继续使用 JavaScript API。
所以我知道如何继续,但我不确定这是最明智的方法。 我的工具集是 ASP.NET、C#、Dojo、ESRI JavaScript API 和 JavaScript:
- web.config 中包含到数据库的连接字符串
- JavaScript 必须与 C# 函数交互
- C# 函数应该位于 aspx 的“代码隐藏页面”上页。
- 我想我需要实现一个没有回发的客户端回调,如本文所述 http ://msdn.microsoft.com/en-us/library/ms178208.aspx
- 然后我可以使用返回的回调数据再次在客户端使用 JavaScript API 继续我的快乐之路。
Here is my scenario:
- User enters in address
- Address is geolocated
- Geolocation is buffered (1 ft)
- 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:
- Connection string to the database goes in web.config
- JavaScript will have to interact with C# function
- C# function should be on the “code behind page” of an aspx page.
- 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
- Then I can use the callback data returned to move on my happy way with the JavaScript API on the client side again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你让客户端回调的事情变得太复杂了。
创建一个以 JSON 或 XML 形式返回记录的 Web 处理程序,并将道路 ID 作为处理程序的查询字符串参数。
通过 JavaScript 中的 AJAX 调用来调用处理程序。
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.