开发者

Refresh the Grid Automatically when table changes in the DB

I am having the Windows application accessing the internal server and creating the setup file based on the user request from the Front End application.

1) When we request the server for creating the setup file from the Front End application we will add details into开发者_运维问答 the table.(req id="101", Status="Started" and etc) and showed those entries in the Grid .

2) We process the request from the server based on the FIFO (Queue) and create the setup file. Once setup file is created we will update into the table status="Completed".

Problem : Once we update status of the request into table (Done in the server) we need to refresh the Grid in the Front End application.

I don't want to put the timer in the form to refresh the datasource. Is any other way to achieve this ?

My data retrival statment in my c# program

public DataTable GetCustomPatchGridDatasource(string Requesteduser)
        {
            try
            {
                dbConn = new DBConnection();
                myconn = dbConn.CreateConnection();
                myCommand = new SqlCommand();
                myCommand.CommandText = "sp_Patch_GetPatchDetails";
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.Parameters.Add(new SqlParameter("@RequestedUserEmail", Requesteduser));
                myCommand.Connection = myconn;
                myDatatadapter = new SqlDataAdapter(myCommand);
                datatable = new DataTable();
                myDatatadapter.Fill(datatable);
                dbConn.CloseConnection();
                return datatable;
            }
            catch (Exception ex)
            {
                dbConn.CloseConnection();
                MessageBox.Show(ex.Message, "Message");
                return null;
            }
        }


Use INotifyPropertyChanged Event.


You can use a trigger to output the fact of a new row into a special log table table. Then you could create a web service that returns true or false if there are new rows in that log history table. After the new rows are processed you can delete them and so on. You can use jQuery with timer to ajax call into your webservice, get response, and update your control based on what the web service returns. May be there are easier ways to do that as well, but I would not monitor my main table constantly for new rows due to obvious performance issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜