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!

3
  • 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? Commented 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. Commented 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. Commented Oct 10, 2019 at 7:03

1 Answer 1

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

}

1
  • 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. Commented Jan 16, 2017 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.