You won't be able to connect directly to the SQL database using javascript. You will need to use some server side code to make the table information available as a web service. There are a number of ways to do this. If you have access an ArcGIS server, you could create a published python geoprocessing service that queries a SQL server table and returns the table, then use javascript to execute the service and make the data available to the cilent. At ArcGIS Server 10+, you may also be able to access be able to access a table as part of a map service. We are still on 9.3.1, so I can't say for sure.
The usual way to handle a demand of accessing a SQL server outside ArcGis server is to write a REST service at a web server that will handle the request and returning data. In JavaScript you can easily consume such a request by code like this base on JQuery
$.ajax({
cache: false,
type: "POST",
async: false,
url: �??rest service url�?�,
crossDomain: true,
data: JSON.stringify(data),
contentType: "application/json;charset=utf-8",
dataType: "json",
processdata: true,
success: function (data) {
if (!status)
alert("data retrieve failed");
else
�?�.. data handling
},
error: function (xhr) {
alert(xhr.responseText);
}
});
Writing REST services is not an ArcGis API issue, but pure writing web services. Currently I am writing a custom graphic layer class that will consume non ArcSDE geometry tables like the SQLGeometry of MS SQL server. I hope later to make the code available. The REST service is written using .NET
is this fine,but in this request what url i have to be placed.this is sqlserver query purose na
Hello
Best way is that (if you are using ArcGIS DT 10.0 and Server 10.0)
1.Create query layer in ArcMap ( click here)
2.Publish as map service in ArcGIS Server..
3.Use REST service for query in java script API.. It will resolve your issue ( Check query task in AGS_JSAPI) all the best : )
I know rest service with url,but with out that service url how can i communicate sqlserver table with front end map.........i want connections in programming side from sqlserver to client side map.that map is tiled or dynamic......