ASP.NET - How to show a pop up message when a record is added in the SQL SERVER database

Asked By dinesh on 10-Apr-13 08:58 AM
Hi friends,

       I have an web application in with MVC 4.0. My requirement is when ever my web application is opened a pop up should be showed with the newly added record in the table of Sql server database.
How to do this.

With Regards,
Erik Little replied to dinesh on 13-Apr-13 01:26 PM
I do not know the fields you're querying but I can get you started.

--This example shows how to use the web api with the mvc controller. This might not be what you need but it is a little easier to understand and use, just my personal opinion.

-SQL Query

--ID should be a incremental primary key

create proc proc_GetRecords
@LastRecordID INT
SELECT * FROM MyTable mt WHERE mt.ID > @LastRecordID

//when the window opens call your MVC controller

//if you did not pass a lastrecordID check the localstorage of the browser
function GetRecords(lastrecordID) {

    lastrecordID = lastrecordID || window.localStorage.getItem('lastrecordID');
    autoOpen: true,
    height: 'auto',
    width: 'auto',
    //position: [$(,
    //   $( + 40],
    open: function (event, ui) {
      type: "GET",
      cache: false,
                      //the web api controller your working with
      async: false,
      success: function (data) {
   lastrecordID = data.records[data.records.length-1].ID
      if (!lastrecordID || lastrecordID <1) {
        //no new record then return with out doing anything
  //store the last lastrecordID in localstorage
  window.localStorage.setItem('lastrecordID', lastrecordID); //do something with the records data

--web api controller

public class LastestRecords : ApiController
    public HttpResponseMessage Get( int id)
      //var lastestRecords=  //call sql query context.proc_GetRecords(id);
return Request.CreateResponse(HttpStatusCode.Created, new { records = lastestRecords }); ;