1

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 Jan 16 '17 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. – YungGun Jan 16 '17 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 Oct 10 '19 at 7:03
0

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());
}

}

| improve this answer | |
  • 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. – YungGun Jan 16 '17 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.