Remoting( Database as a Model , in a MVC pattern)
-
I need to know how would i remotely call methods on another pc(program) when my database(sql) changes(update occurs).I need to notify my viewing program(GUI) of the changes allowing immediatly show the changes as the database changes. How would this be done in C#. Triggers? I am very new to C# links to some nice tuts would be helpful as well as any other suggestions on how i would tackle this. Thank you:confused:
-
I need to know how would i remotely call methods on another pc(program) when my database(sql) changes(update occurs).I need to notify my viewing program(GUI) of the changes allowing immediatly show the changes as the database changes. How would this be done in C#. Triggers? I am very new to C# links to some nice tuts would be helpful as well as any other suggestions on how i would tackle this. Thank you:confused:
There are plenty of ways I'm sure, but I've always had the best success with custom TCP protocols. Meaning, you would connect to the remote computer through a TCP Client on a dedicated port, and send your own message format to the remote computer. The remote computer should have a thread that is constantly listening on that port for new connections. When it receives your connection, it verifies that it came from you (your custom message format should have a username/password in it), and performs the necessary operation based on the message. This approach has yet to fail me.
-
There are plenty of ways I'm sure, but I've always had the best success with custom TCP protocols. Meaning, you would connect to the remote computer through a TCP Client on a dedicated port, and send your own message format to the remote computer. The remote computer should have a thread that is constantly listening on that port for new connections. When it receives your connection, it verifies that it came from you (your custom message format should have a username/password in it), and performs the necessary operation based on the message. This approach has yet to fail me.
-
that sound great, is there perhaps some links to samples explaining in more detail, as i said i am new to programming. thanx again:~
If you've never set up a TcpClient, studio 2005 makes it pretty easy. Same for the TcpListener on the remote computer. //DataBase Computer TcpClient m_connection = new TcpClient("15.3.6.33", 17534); StreamWriter m_writer = m_connection.GetStream(); m_writer.WriteLine("(app)(username)mel(/username)(password)mel(/password)" + "(command)REFRESH(/command)(/app)"); //Remote Computer TcpListener m_listener = new TcpListener(17534); TcpClient m_connection; StreamReader m_reader; String strCommandText; m_listener.Start(); while(true) { if (m_listener.Pending()) { m_connection = m_listener.AcceptTcpClient(); m_reader = m_connection.GetStream(); strCommandText = m_reader.ReadLine(); // Now parse your message to find out what you should do. } } -- modified at 18:16 Tuesday 30th August, 2005