1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

MSSQL to C#

Discussion in 'C#' started by Mr.President, Nov 22, 2011.

  1. Mr.President

    Mr.President New Member

    Joined:
    Apr 25, 2010
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    0
    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:
            //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());
                }
            }
     

Share This Page