0

I have created an application which utilises a database to store information , how do I now allow that information to be updated from any computer connected along the same LAN. so once someone entered and saves new information them all other databases in the same app will update .

    Private Sub MLGMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Timer1.Start()
    'how do i get MLGDatabaseDataSet to be a file path here'
            Me.LocationRecordTableAdapter.Fill(Me.MLGDatabaseDataSet.LocationRecord)

    End Sub


        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        UPDATETIME = UPDATETIME + 1
        Label1.Text = UPDATETIME
        If UPDATETIME > 700 Then

            '---------------------------------------UPDATE DATABASE-----------------------------------------'

            LocationRecordDataGridView.Refresh()
            LocationRecordDataGridView.DataSource = Nothing
            LocationRecordDataGridView.DataSource = ("C:\Users\User\Documents\folder\MLGDatabase.sdf")
            Me.LocationRecordDataGridView.DataSource = LocationRecordBindingSource
            LocationRecordBindingSource.RemoveFilter()
            LocationRecordDataGridView.Refresh()
            LocationRecordDataGridView.Refresh()
            UPDATETIME = 0
        End If
End Sub

1 Answers1

0

I don't have enough rep yet to just post a comment, but my first question is, if this is a LAN-based application, isn't everyone pulling from the same database? Once you update the database from one user, the database should be updated for everyone. Of course, if you've got a record source displayed, such as in a DataGridView, you may need to implement a timer to refresh your data source periodically. If you're using an RDBMS (SQL Server, PostgreSQL, MySQL, etc.), this should be pretty simple.

I guess a big part of the equation is going to depend on the type of database you're using, and where that database is actually located.

G_Hosa_Phat
  • 976
  • 2
  • 18
  • 38
  • the database is in my VB application, each computer will have this application, how do i actually get the data to be updated . I i dont know what function to use to go about this but i know the timer has to be implemented at the end of the creation of the function –  Jul 18 '13 at 14:36
  • What kind of database are you connecting to from the application to populate your DataSet/DataTable in the application? MS Access? PostgreSQL? When you launch your application and go to display the data on your form, I'm assuming you are using a DataSet/DataTable objet you have created in the project. But, where are you getting the data to put into that DataSet? – G_Hosa_Phat Jul 18 '13 at 15:49
  • So, this is a SQL Compact database, then? If you are looking for multi-user support (and you don't want to learn a whole new database system or pay for a full-blown MS SQL Server database server), it would probably be better to look into SQL Server Express. Check out [this SO post](http://stackoverflow.com/questions/1992713/sql-server-ce-in-a-multi-user-scenario-is-this-really-really-stupid) for some good info. If you decide to make the switch, though, you'll also want to check out [this MSDN page](http://msdn.microsoft.com/en-us/library/ms165647(v=sql.90).aspx) as well for LAN connections. – G_Hosa_Phat Jul 19 '13 at 04:34
  • Quick synopsis: SQL CE is designed for embedded systems (mobile devices, _et. al._), SQL Express is the "entry point" for MS SQL database servers with multi-user access. Of course, you _can_ migrate to a much more robust system that's truly designed for multi-user environments (many open-source/free options are available, such as PostgreSQL or MySQL), but those would require much more of an investment in time and effort just to get started. – G_Hosa_Phat Jul 19 '13 at 05:03
  • One other option that I failed to mention would be to migrate to a Microsoft Access database (or some other, similar file-based database) using OLEDB or ODBC for connection and interaction, and locate the file on a central network share (\\server\share\YourMSAcessDB.mdb). If you stick with SQL CE, you're probably going to end up having to do a lot of file copying back and forth between computers, and you'll end up more frustrated than anything because you'll inevitably end up losing data frequently due to one user's changes overwriting another's. – G_Hosa_Phat Jul 19 '13 at 12:08
  • I see , thats just it . I want users change to overite other, i have made it so that there are 2 login options in my database application and only 3 persons and overite data soo that everyone else can simply view the data :) . so I will go with SQL . I read that i just need to "install SQL server on server pc with a SQL Managment Studio attach the database in the server then in each computer add the data base from another computer you must enable the firewall to allow the SQL path through it, add the 2 ports: 1) 1344 as tcp, and 1343 as udp." –  Jul 19 '13 at 13:55
  • by default my "MLGDatabaseDataSet.sdf" is located in my debug folder where it read from and written to during runtime . so with my database there what exactly are the steps in need to take to ensure that it will only read and write to the database in the SQL server and not the database in mt Debug folder , or do i need to keep the database in my debug folder too and also point to the SQL server . I have never used SQL so this is why i'm having so much trouble understanding . –  Jul 19 '13 at 13:55
  • 1
    If you're using SQL Server, you won't really have a "file" to which your application will connect, so your Debug folder won't really matter. You'll just connect to the database service that's running on the specified server computer (with the appropriate credentials, for your security requirements), and pull the data from the appropriate "catalog". The link you posted should help in establishing the connection and getting your data. I'm not terribly familiar with MS SQL Server (I use a combination of MySQL/PostgreSQL/MS Access at work), but it shouldn't be too difficult. – G_Hosa_Phat Jul 19 '13 at 17:05