Click here to Skip to main content
15,888,802 members
Home / Discussions / ASP.NET
   

ASP.NET

 
SuggestionRe: How to Restore Multiple .BAK files at a time in sql server 2008 anybody can tell me the correct way Pin
Kornfeld Eliyahu Peter31-Aug-14 22:50
professionalKornfeld Eliyahu Peter31-Aug-14 22:50 
GeneralRe: How to Restore Multiple .BAK files at a time in sql server 2008 anybody can tell me the correct way Pin
Member 1104982531-Aug-14 23:10
Member 1104982531-Aug-14 23:10 
QuestionSuggestions for ways to store secret data in a html file Pin
jkirkerx30-Aug-14 16:51
professionaljkirkerx30-Aug-14 16:51 
AnswerRe: Suggestions for ways to store secret data in a html file Pin
Anurag Gandhi31-Aug-14 10:13
professionalAnurag Gandhi31-Aug-14 10:13 
GeneralRe: Suggestions for ways to store secret data in a html file Pin
jkirkerx31-Aug-14 10:26
professionaljkirkerx31-Aug-14 10:26 
GeneralRe: Suggestions for ways to store secret data in a html file Pin
jkirkerx31-Aug-14 11:31
professionaljkirkerx31-Aug-14 11:31 
QuestionHow to Notify change while inactive of web site developed by ASP.Net Pin
Tridip Bhattacharjee28-Aug-14 21:44
professionalTridip Bhattacharjee28-Aug-14 21:44 
QuestionIssue regarding implementing SQL Dependency in Application_Start event Pin
Tridip Bhattacharjee28-Aug-14 4:26
professionalTridip Bhattacharjee28-Aug-14 4:26 
i through i will call SQL Dependency related code Application_Start event and my objective will be completed. my scenario is i have a routine in my web application which i invoke manually just clicking on a button when data updated in sql server table. i was told to make this process automated.

so i go through couple of article on SQL Dependency and through i can make my manual process automated by SQL Dependency because we can monitor table change by SQL Dependency and SQL Dependency can notify us when change done.
please see my code

C#
protected void Application_Start(Object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlDependency.Stop(connectionString);
            System.Data.SqlClient.SqlDependency.Start(connectionString);
            RegisterNotification();
        }
        static SqlDependency dep;
        private static void RegisterNotification()
        {
            string tmpdata = "";
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "SELECT ActivityDate FROM [bba-reman].ContentChangeLog";
                    dep = new SqlDependency(cmd);
                    dep.OnChange += new OnChangeEventHandler(OnDataChange);
                    SqlDataReader dr = cmd.ExecuteReader();
                    {
                        while (dr.Read())
                        {
                            if (dr[0] != DBNull.Value)
                            {
                                tmpdata = dr[0].ToString();
                            }
                        }
                    }

                    dr.Dispose();
                    cmd.Dispose();
                }
            }
            finally
            {
                //SqlDependency.Stop(connStr);
            }

        }

        static void OnDataChange(object sender, SqlNotificationEventArgs e)
        {
            SqlDependency dep = sender as SqlDependency;
            dep.OnChange -= new OnChangeEventHandler(OnDataChange);
            SiteSearch.CreateIndex(false);
            RegisterNotification();
        }

        protected void Application_End(Object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlDependency.Stop(connectionString);
        }



the above code was running fine but i faced a good problem. suppose no visitor is visiting our web site and at the same time if some one change sql data by a win apps then i saw OnDataChange() event is not firing but if at least one visitor is with our site then OnDataChange() event is firing properly.

may be this is default nature of asp.net engine. i could use SQL Dependency in win service or in winform apps but i have some constrain because the routine which i am calling after detection of data change in db that is in our web application.

So please guide me what i can do as a result OnDataChange() event should always fire if no visitor is visiting our web site.

thanks
tbhattacharjee

QuestionNo relevant Source lines in visual studio 2012 Pin
swathi(MCA)27-Aug-14 19:54
swathi(MCA)27-Aug-14 19:54 
AnswerRe: No relevant Source lines in visual studio 2012 Pin
Richard MacCutchan27-Aug-14 22:23
mveRichard MacCutchan27-Aug-14 22:23 
AnswerRe: No relevant Source lines in visual studio 2012 Pin
Kornfeld Eliyahu Peter27-Aug-14 22:35
professionalKornfeld Eliyahu Peter27-Aug-14 22:35 
QuestionFlipKart Api Sample Code Pin
harshbollu26-Aug-14 19:53
harshbollu26-Aug-14 19:53 
AnswerRe: FlipKart Api Sample Code Pin
raju melveetilpurayil2-Sep-14 14:14
professionalraju melveetilpurayil2-Sep-14 14:14 
AnswerRe: FlipKart Api Sample Code Pin
Sibeesh KV29-Sep-14 1:27
professionalSibeesh KV29-Sep-14 1:27 
Questionhow to use datapager with repeater in asp.net Pin
harshbollu26-Aug-14 19:40
harshbollu26-Aug-14 19:40 
AnswerRe: how to use datapager with repeater in asp.net Pin
Richard Deeming27-Aug-14 2:36
mveRichard Deeming27-Aug-14 2:36 
GeneralRe: how to use datapager with repeater in asp.net Pin
sankarsan parida5-Sep-14 20:55
professionalsankarsan parida5-Sep-14 20:55 
QuestionCrystal report is not displaying for chrome browser but working finr with IE and firefox Pin
sma123#25-Aug-14 22:20
sma123#25-Aug-14 22:20 
AnswerRe: Crystal report is not displaying for chrome browser but working finr with IE and firefox Pin
jkirkerx26-Aug-14 9:04
professionaljkirkerx26-Aug-14 9:04 
QuestionDatalist onitemcommand Pin
Otekpo Emmanuel24-Aug-14 2:56
Otekpo Emmanuel24-Aug-14 2:56 
AnswerRe: Datalist onitemcommand Pin
Richard MacCutchan24-Aug-14 4:51
mveRichard MacCutchan24-Aug-14 4:51 
GeneralRe: Datalist onitemcommand Pin
Otekpo Emmanuel24-Aug-14 11:49
Otekpo Emmanuel24-Aug-14 11:49 
QuestionDatalist onitemcommand Pin
Otekpo Emmanuel24-Aug-14 2:36
Otekpo Emmanuel24-Aug-14 2:36 
AnswerRe: Datalist onitemcommand Pin
Richard MacCutchan24-Aug-14 4:52
mveRichard MacCutchan24-Aug-14 4:52 
GeneralRe: Datalist onitemcommand Pin
Otekpo Emmanuel24-Aug-14 19:52
Otekpo Emmanuel24-Aug-14 19:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.