Link to home
Start Free TrialLog in
Avatar of Marianne VAN WYK
Marianne VAN WYKFlag for South Africa

asked on

Best way to start writing an api for SQL server 2017

I am new to writing API's, and was wondering where the best place to start was with writing a RESTful API for a locally hosted SQL2017 server. I have written an app using angular, and wish to access my data that is located on the local network (installed on a windows 10 machine) through a API.
I already have a VB.net project that connects to the database (each practice has a local server and program that connects through the local network).  I am writing a app to give more functionality to the clients, and need to access this data from the newly written app (using ionics and angular, writen in visual studio code).   As I am new to API's, I was wondering where the best place was to start, or any good examples on how to build a basic api.  I would also like to know if I can integrate this into the existing VB.net project, as the project and sql server are already at clients.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

As a start, I would suggest you to create a WCF service architecture from Visual Studio.

User generated image
And then from the back end, just linked it to SQL Server's Database Logic, like connecting with stored procedures, etc. You should able to find some relevant codes online too.
Avatar of Marianne VAN WYK

ASKER

Why would a WCF service be better than a normal web api? Is it easier to implement in a already existing project?

And would I be able to change the connection string of the WCF service? Since each server is hosted on the practices local network, the server settings must be able to be selected. In our VB.net project we use the SQL server browser to search for servers on the network and then set each application to the installed server (for example, "SERVER-PC\SQL2017").  This varies for each practice and I will have to be able to set this connection string in each instance.
Yes in my opinion, you would be better off with Web API instead of WCF. While it is entirely possible to store connection string in app.config and then load it during run time in WCF, today if I have to develop an API, I will go with Web APIs as it reduces complexity (or maybe it is perceived complexity).
I am bit confused about your multiple Database per practice scenario though. The api you are building is going to serve every Desktop app? or it is going to be hosted per practice?
This varies for each practice and I will have to be able to set this connection string in each instance.

well, it depends on the requirements to determine whether to implement a WCF or Web API structure. I believe we can read a lot regarding these comparison online. of course the use or store of connection string isn't really the show stopper to determine what technologies to be implementing.
@Ryan Chong-  Would I be able to change the connection string dynamically if I used a WCF? Most people seem to reccomend a normal API, which is why im unsure?


The scenario for each practice is as follows:  we install a sql server 2017 on to a windows 10 machine, and then install our initial program as well (on as many computers as they want).  This practice then all changes the connection string of each program (through a dropdown box using the sql browser), to connect to the SQL server on the "server" computer (which is just any computer that has the sql server). We only use the local network to connect to the server, so I need the API to be on the local network, and be able to set the connection string (if the server computer is named main-deskop,  then the connection is "main-desktop\SQL2017").   Since each practice will have their own "server" computer, and the name and ip will vary each time, I will need to be able to point the api to the server computer at each practice. My newly developed app will then use the API to perform CRUD operations.

I hope this makes more sense?
ASKER CERTIFIED SOLUTION
Avatar of Marianne VAN WYK
Marianne VAN WYK
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
While most of the things will remain same, current version of .Net Core is 3.1, I would recommend going with it. All the best.