As in the title, I would like to create a Sharepoint hosted add-in that accesses data from an SQL database on my companies database. Is there any way to do this? Thank you!
-
In any way you need some service layer which will act as gateway between your add-in and database. In that case why do you need sharepoint-hosted add-in? Don't you think it's simpler to create provider hosted with Entity Framework or LINQ 2 SQL or any other data access?Sergei Sergeev– Sergei Sergeev2017-01-16 15:34:21 +00:00Commented Jan 16, 2017 at 15:34
-
@SergeiSergeev Yes I agree a provider hosted add-in makes more sense, however my supervisor said we can't host a server specifically for this so I have to use a sharepoint hosted one, if my understanding is correct. Thank you for the response.ICW– ICW2017-01-16 18:07:16 +00:00Commented Jan 16, 2017 at 18:07
-
You don't need an expensive server. A web app in Azure works as the "provider" of a provider hosted app. It costs a few dimes and requires little maintenance.Gil Roitto– Gil Roitto2019-10-10 07:03:23 +00:00Commented Oct 10, 2019 at 7:03
Add a comment
|
1 Answer
Look at this can help you ..
function webProxy() {
var context = SP.ClientContext.get_current();
var request = new SP.WebRequestInfo();
request.set_url("http://services.odata.org/Northwind/Northwind.svc/Categories?$format=json");
request.set_method("GET");
var response = SP.WebProxy.invoke(context, request);
context.executeQueryAsync(success, fail);
function success() {
if (response.get_statusCode() == 200) {
var categories = JSON.parse(response.get_body());
var message = jQuery("#message");
message.text("Categories in the remote Northwind service:");
message.append("<br/>");
jQuery.each(categories.d.results, function (index, value) {
message.append(value.CategoryName);
message.append("<br/>");
});
} else {
var errorMessage = response.get_body();
alert(errorMessage);
}
}
function fail(sender, args) {
alert("Call failed. Error: " +
args.get_message());
}
}
-
Thanks for the response. This shed some light on how I might approach it if my data could be got via a http request, but I don't know if this particular SQL server is capable of that. I will look into it.ICW– ICW2017-01-16 18:38:32 +00:00Commented Jan 16, 2017 at 18:38