locked
Share a database table in one application with another application RRS feed

  • Question

  • User-972017328 posted

    I have two different applications that are presently up and running online.  One application is a lab program and the other is an inventory program.  The lab program has a table called "Patients" that I would like to access in the inventory program. 

    How would I go about accessing the "Patient" table and utilizing that data in the Inventory Program? 

    Would I need an API, Web Service or some other method?

    Thanks

    Wednesday, May 15, 2019 1:28 PM

All replies

  • User475983607 posted

    RoboDent

    How would I go about accessing the "Patient" table and utilizing that data in the Inventory Program? 

    • Use connection strings that access each DB.  Write queries that grab the data you want and massage the data in C# (or VB.NET).
    • Use fully qualified names and an account that has access to both DBs to create a query that access both DBs if the DBs are on the same server.
    • Write stored procedure in one the DB to query both DB tables.  This assumes the DBs are on the same server.
    • Craft a linked server if the DBs are on different servers.

    RoboDent

    Would I need an API, Web Service or some other method?

    A web service is just a URL endpoint to execute code.

    Wednesday, May 15, 2019 1:35 PM
  • User-2054057000 posted

    How would I go about accessing the "Patient" table and utilizing that data in the Inventory Program? 

    Would I need an API, Web Service or some other method?

    Thanks

    Through API you can expose all the data of your Patient table in JSON. Thus clients can easily access this data. Please refer these 2 API tutorial:

    1. Creating API in ASP.NET Core

    2. Consuming an API in ASP.NET Core

    Regards...

    Wednesday, May 15, 2019 3:27 PM
  • User-1174608757 posted

    Hi RoboDent,

    According to your description, could you please tell me that whether these two applications are on the same server?

    If they are on same sever, you could directly add connecting string for different application.You could add connection string in the web.config file of web application which you could see as below:

     <connectionStrings>
        <add name="mssqlserver" connectionString="Data Source=(localdb)\xxxx;Initial Catalog=Mydatabase;Integrated Security=True" providerName="System.Data.SqlClient"/>
      </connectionStrings>

    Else ,if this two web applications are in different servers.One way you could try is that connecting to server to realize a remote connection.You could follow the links as below:

    https://blogs.msdn.microsoft.com/sqlexpress/2005/05/05/how-to-configure-express-to-accept-remote-connections/

    What's more ,  you could also create a WebApI for sharing database connection for different server. Here is the link for how to create a Web Api for database.

    https://medium.com/@maheshi.gunarathne1994/building-a-restful-api-with-asp-net-web-api-and-sql-server-ce7873d5b331

    Best Regards

    Wei 

    Thursday, May 16, 2019 2:44 AM