none
Can C# Window Form Application be used by multiple personal at the same time? RRS feed

  • Question

  • If I build an C# Window Form application and put it in workplace share drive (local workplace drive, every colleague can access).

    The application will involve username/password to access server database (see below sample code), that being said, there is form asking for username/password.

    Since I heard that: For access application, it is recommended that everyone saves a copy of application and run the application on his/her own folder. But is there any problem for multiple persons running the application at the same time?

    Let me give an detailed example of my concern: there is a form containing DataGridView, there are also ComboBox in the form for user to filter the table data. Let us say Person1 and Person2 run the application at the same time, there is DataGridView linked to server database table Customer, there is dropdown combox for user to filter customer by State, if Person1 chooses CA and Person2 chooses NY, will CA customer data shows up on Person1's computer screen and NY customer data shows up on Person2's computer screen?  Since both persons run the same application from the same folder, can the application handle the different information correctly?

    The other question is: see below code, I have two textbox for Username/Password, if Username/Password is incorrect, Form Login will stay there; if Username/Passoword is correct, Form Login will disappear and another form shows up. I need to pass the Username/Password to the other form, so that people can use Username/Password to filter Customer data (When Person1 wants to filter CA Customer data, the Program will use his Username/Password to handle the filtering). But where are Username/Password saved? Computer cache? Is there any kind of this possibility: Person1 enters his Username/Password at 10:01 am, and Person2 enters her Username/Password at 10:03, at 10:06am Person's wants to filter CA customer data, will program use Person1's Username/Password or Use Person2's Username/Password? Since Person2 is the most current person entering the Username/Password?

    Thanks.

    OdbcConnection Cn; 
    Username = txtUsername.Text;
    Password = txtPassword.Text;
    ConnectionString = "Driver={Adaptive Server Enterprise};server=*****;port=*****;db=xyz;uid=" + Username + ";pwd=" + Password + ";";
    
    Cn = new OdbcConnection(ConnectionString);


    • Edited by VA_er Sunday, March 10, 2019 6:25 PM
    Sunday, March 10, 2019 6:16 PM

All replies

  • Typo (new user, frequently identified as spam, it seems it can only allow me edit once or twice): 

    ............Person1 enters his Username/Password at 10:01 am, and Person2 enters her Username/Password at 10:03 am. At 10:06am Person1 wants to filter CA customer data, will program use Person1's Username/Password or Use Person2's Username/Password? Since Person2 is the most current person entering the Username/Password?

    Sunday, March 10, 2019 6:35 PM
  • Let me give an detailed example of my concern: there is a form containing DataGridView, there are also ComboBox in the form for user to filter the table data. Let us say Person1 and Person2 run the application at the same time, there is DataGridView linked to server database table Customer, there is dropdown combox for user to filter customer by State, if Person1 chooses CA and Person2 chooses NY, will CA customer data shows up on Person1's computer screen and NY customer data shows up on Person2's computer screen?  Since both persons run the same application from the same folder, can the application handle the different information correctly

    No there is no conflict there. Each use is working independently from each other. The only  issue will be data persistence with the database and users trying to update a record in a table concurrently. If you don't prevent it, then last user wins and that the data that will be saved, and it may not be the data that should be saved.

    The other question is: see below code, I have two textbox for Username/Password, if Username/Password is incorrect, Form Login will stay there; if Username/Passoword is correct, Form Login will disappear and another form shows up. I need to pass the Username/Password to the other form, so that people can use Username/Password to filter Customer data (When Person1 wants to filter CA Customer data, the Program will use his Username/Password to handle the filtering).

    I have to question what you are doing here it makes no sense. A user-id and password are used for security purpose for user to login and use the program in general. It is not used in some data filtering logic.

    But where are Username/Password saved? Computer cache? Is there any kind of this possibility: Person1 enters his Username/Password at 10:01 am, and Person2 enters her Username/Password at 10:03, at 10:06am Person's wants to filter CA customer data, will program use Person1's Username/Password or Use Person2's Username/Password? Since Person2 is the most current person entering the Username/Password?

    A user's user-id and password are kept in a database table called a User table. The user's login credentials are validated against the data kept in the User table.

    Also you should look into what is client/server architectural style where the server code has the database code and the client program sitting on the user's computer uses the server program for database access..

    https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ee658117(v=pandp.10)

    Sunday, March 10, 2019 9:58 PM
  • I have to question what you are doing here it makes no sense. A user-id and password are used for security purpose for user to login and use the program in general. It is not used in some data filtering logic.

    I understand your point, but I don't know the information about which server database table has User Table (credentials, whatever you call it), I don't work for IT department, and I am not IT professional, and I am just building application for team members, so forget about User table. As above sample code shows, this program will use the code to test opening database, if successfully opening the database, then Username/Password is correct. Therefore, the program needs to hold Username/Password for later use, filtering data will require running query, in Form Login, program uses connection string to open database, if successful, then close the database, and switch to another form, where user can filter the data. When filtering the data, the program will again need to use connection string (Username/Password) to open database. I know it does not make sense, but that is the way I am planning to build the program.

    A user's user-id and password are kept in a database table called a User table. The user's login credentials are validated against the data kept in the User table.

    Also you should look into what is client/server architectural style where the server code has the database code and the client program sitting on the user's computer uses the server program for database access..

    Same as above explanation, I need the program to hold Username/Password somewhere. When I build VBA excel application, the program puts Username/Password in two cells in hidden worksheet, so every time when user interacts with database, program will use Username/Password from the two cells. It is not perfect solution, but it function well. Don't ask me why not going to IT department for User table information, it is big organization, very bureaucratic 

    https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ee658117(v=pandp.10)




    • Edited by VA_er Sunday, March 10, 2019 10:23 PM
    Sunday, March 10, 2019 10:22 PM
  • It's best to use an executable that is on a shared drive for consistency and maintainability. Each user that fires up the executable knows nothing about the any other user using the executable.

    When it comes down to multiple users access the same database and tables, that now is that a C# concern but a concern of SQL-Server being setup properly along with the chances that the same record(s) will be altered at the same time which can be handled to some degree with a last update field e.g. read the record that may be updated and remember the last update value, prior to performing the update see if the remembered value is the same as when reading the data, if changed well someone updated the record as the rule for the update would be to perhaps have a trigger to update the last update date-time.

    last update column

    ADD LastUpdated DATETIME2 NULL DEFAULT GETDATE()

    Trigger

    CREATE TRIGGER tgr_modstamp
    ON **TABLENAME**
    AFTER UPDATE AS
      UPDATE **TABLENAME**
      SET LastUpdated = GETDATE()
      WHERE **ID** IN (SELECT DISTINCT **ID** FROM Inserted)
    But nothing is 100% no matter what database is being used.


    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

    Sunday, March 10, 2019 10:57 PM
    Moderator
  • When I build VBA excel application, the program puts Username/Password in two cells in hidden worksheet

    That's the problem here is that you are trying to apply some VBA and  Excel skills,  for what that's worth,  and COM with what you have done in the past to C# and .NET.

    They are not the same thing,  and they are not the same platforms that is VBA and Excel as opposed to C# and .NET as opposed to COM.

    You need to toss out everything you know and have done with using VBA, Excel and COM tossing  them out the window. You need to go get yourself  a beginner's book and learn how to build simple desktop solutions using C# and the .NET platform.  

    That's if you want to be successful.

    https://www.onlinebooksreview.com/articles/best-c-sharp-programming-books


    • Edited by DA924x Monday, March 11, 2019 5:09 AM
    Monday, March 11, 2019 5:07 AM