Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   MSSQL to C# (http://www.go4expert.com/forums/mssql-c-sharp-t27200/)

Mr.President 23Nov2011 01:51

MSSQL to C#
 
I have a MSSQL table in which the news will be stored
now if a new record is added to the db then my application will pop up a messagebox !

MyCode : This application will continuously check the database to see weather a new row is added if added then it will display a message box

my Question is; is this a good method ? or are there any other way to accomplish this ? please advice:pleased:
PHP Code:

        //start thread 
        
private void Form1_Load(object senderEventArgs e)
        {
            
th1 = new Thread(new ThreadStart(tm_Tick));
            
th1.Start();
        }
 
        
thread dunction
        
private void tm_Tick()
        {
            
clsFetch db = new clsFetch();
            
int x db.maxPKID(); // get maximum primary key 
            
int y 0;
 
            try
            {
                while (
_stopThreads == false)
                {
                    
lock (this)
                    {
                        
db.maxPKID();
                        if (
x)
                        {
                            
MessageBox.Show(db.getMessage(db.maxPKID));
                            
y;
                        }
                    }
                }
            }
            catch (
Exception ex)
            {
                
MessageBox.Show(ex.ToString());
            }
        } 



All times are GMT +5.5. The time now is 06:20.