Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
–
–
The first thing that you need to consider is that there is no immediate and extremely effective solution and you have to decide what frameworks and tools to be used. And as mentioned in the comment that the market for this scenario is very small. But there are some ways that you can handle this.
Remote storage sample solution:
Here is a basic example of how you should implement this. It was also cited in this
SO post
:
Client application
The client application can be any application the user typically uses.
Some examples:
Mobile app (written in native, Dart, Xamarin, ...)
Desktop app (Electron, WPF, ...)
Website app (Angular, React, Vue, ...)
The API is there to retrieve data, and change data. But It will also
handle authentication, authorization, logging, doing business logic
Database
Your API will then execute queries, inserts, updates, deletes, execute
stored procedures on the Database of your choice. In your example SQL
Server.
There are many possibilities on how to set this up, depending on your
skills, knowledge of frameworks, how you want to deploy things.
How you want to deploy this will limit your choices as well. For your
Serverless API (Via Azure Functions, AWS Lambda)
Cloud Website (Azure Web Apps)
Website hosted on premise
Docker container
In real life scenarios this often gets more complex with Firewalls,
Application Gateways, Virtual networks, clusters.
You can install a SQLServerSocket on your server:
https://github.com/nippur72/SqlServerSocket
Install and execute SqlServerSocket.exe in the background on the server machine where SQL Server is installed.
Also, you need a client:
https://github.com/nippur72/SqlServerSocket/tree/master/DartClient
And you can try some connections and queries directly to your DDBB:
// creates a connection
var conn = new
SqlConnection("SERVER=localhost;Database=mydb;Trusted_connection=yes");
// open connection
await conn.open();
// runs a query returning a single value
var howmany = await conn.queryValue("SELECT COUNT(*) FROM Customers");
// runs a query returning a single row
var myFirstCustomer = await conn.querySingle("SELECT name,age FROM Custormers");
print(myFirstCustomer["name"]);
// runs a query returning all rows
var customers = await conn.query("SELECT TOP 10 name,age FROM Custormers");
for(var customer in customers)
print(customer["name"]);
// execute a command, returning the number of rows affected
var n = await conn.execute("UPDATE Customers SET age=0");
print("zeroed $n customers");
// disconnect
await conn.close();
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.