locked
How to use one database and more PC's? RRS feed

  • Question

  • Hi all,

    I have on my storage via wifi a database file ... 192.168.0.13 (for example) and on each computer is same app. Is some way in C# to check if database file (sqlite) is in use? 

    ... for example: PC1 and PC2 are trying to save data at the same time ... not to malformed database ... not write data with wrong ID ... or something like this ... hope u understand what I need to do ... allow two or more users use same database file with no crashes ... thank you

    Tuesday, October 6, 2020 2:21 PM

Answers

  • Hi, 

    thanks for your answer ... I learn how to use sql server ... so I install sql server, and succesfull connect to database ... SO .. next step is to use same connectionString from another computer? or?



    Connection string would be the same.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by TakeshiKitano Wednesday, October 7, 2020 4:55 PM
    Wednesday, October 7, 2020 3:39 PM

All replies

  • What you are asking about is concurrency control.

    If using Entity Framework Core

    Entity Framework Core Handling Concurrency Conflicts

    Other methods for working with data will be similar along with making some decisions when a conflict arises.

    See also Transaction locking and row versioning.

    All the above is for SQL-Server, Oracle and other providers will implement in their own way.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 6, 2020 2:49 PM
  • First I am very sorry for my english ... I am not sure if I understand this ... so ... should I use this?

    using (SQLiteTransaction trans = con.BeginTransaction()) {

    // sqlite commands trans.Commit(); }




    Tuesday, October 6, 2020 3:13 PM
  •  for example: PC1 and PC2 are trying to save data at the same time ... not to malformed database ... not write data with wrong ID ... or something like this ... hope u understand what I need to do ... allow two or more users use same database file with no crashes ... thank you

    You install a multi user database on a central computer so that two or more uses on other computers can use the database concurrently

    MS SQL Server Express is such a database, which is free to install and use.


    • Edited by DA924x Tuesday, October 6, 2020 3:21 PM
    Tuesday, October 6, 2020 3:21 PM
  • First I am very sorry for my english ... I am not sure if I understand this ... so ... should I use this?

    using (SQLiteTransaction trans = con.BeginTransaction()) {

    // sqlite commands trans.Commit(); }




    Still a concurrency issue

    https://sqlite.org/lockingv3.html

    https://medium.com/@gwendal.roue/four-different-ways-to-handle-sqlite-concurrency-db3bcc74d00e


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 6, 2020 3:35 PM
  • Hi, 

    thanks for your answer ... I learn how to use sql server ... so I install sql server, and succesfull connect to database ... SO .. next step is to use same connectionString from another computer? or?



    Wednesday, October 7, 2020 2:58 PM
  • Hi, 

    thanks for your answer ... I learn how to use sql server ... so I install sql server, and succesfull connect to database ... SO .. next step is to use same connectionString from another computer? or?



    Connection string would be the same.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by TakeshiKitano Wednesday, October 7, 2020 4:55 PM
    Wednesday, October 7, 2020 3:39 PM
  • The connectionstring would be the same for all the computers, but you must configure MS SQL Server for remote connections.

    https://medium.com/@nishancw/how-to-enable-remote-connections-to-sql-server-dc5b6c812b5

    SQL Server has a forum you can post to for help.

    https://docs.microsoft.com/en-us/answers/products/sql-server

    Wednesday, October 7, 2020 4:52 PM