0

i have the specific trouble while binding data from stored procedure to my asp:chart in MS Visual Studio 2010. Unfortunately I wasn't able to find any answer online so I will be really greatful if someone here would be able to help.

I have a database on MS SQL Server, where I use a procedure which generates me data needed for the chart. The data generated look like this.

As you can see at the table, for the first category "1. verze", there is a count of 23 pieces.

It is needed to say that tle last piece was inserted into the database about two hours ago - that means that two hours ago there was just count of 22 pieces.

Now the trouble is that my asp chart still shows the count which was relevant 2 hours ago, and not the up-to-date data: it looks like this.

Please, has someone got any suggestion what might the problem be? My guess is some chache timing for my connection string, however I wasn't able to find such settings of connection string.

My code looks like this:

SqlConnection conn = new SqlConnection((String)ConfigurationManager.ConnectionStrings["Commercial"].ConnectionString);
SqlDataSourceTV.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
SqlDataSourceTV.SelectCommand = "sme.App_Graph_Vers";
SqlDataSourceTV.SelectParameters.Clear();
SqlDataSourceTV.SelectParameters.Add("Graph_type", Graph_type);
SqlDataSourceTV.SelectParameters.Add("AxisX", AxisX);
SqlDataSourceTV.SelectParameters.Add("AxisY", AxisY);
SqlDataSourceTV.SelectParameters.Add("Region", Region);
SqlDataSourceTV.SelectParameters.Add("Banker_navrhovatel", Banker_navrhovatel);
SqlDataSourceTV.SelectParameters.Add("Typ_verze", Typ_verze);
SqlDataSourceTV.SelectParameters.Add("VZN", VZN);
SqlDataSourceTV.SelectParameters.Add("Posledni_verze", Posledni_verze);
SqlDataSourceTV.SelectParameters.Add("Typ_splaceni", Typ_splaceni);
SqlDataSourceTV.SelectParameters.Add("Typ_procesu", Typ_procesu);
SqlDataSourceTV.SelectParameters.Add("Typ_financovani", Typ_financovani);
SqlDataSourceTV.SelectParameters.Add("Typ_rozhodnuti", Typ_rozhodnuti);
SqlDataSourceTV.SelectParameters.Add("Stav", Stav);
SqlDataSourceTV.SelectParameters.Add("Castka", Castka);
SqlDataSourceTV.SelectParameters.Add("DateFrom", DateFrom);
SqlDataSourceTV.SelectParameters.Add("DateTo", DateTo);
SqlDataSourceTV.SelectParameters.Add("Rok", Rok);
SqlDataSourceTV.DataBind();

if (!IsPostBack)
{ ChartTV.DataBind(); }

Parameters (variables) added to the procedure are needed for filtering the data shown on the chart.

duwen_blade
  • 33
  • 1
  • 1
  • 7

1 Answers1

1

Fool I am, I´ve found actually quite simple solution. There is a parameter of SqlDataSource called EnableCaching, the only thing I had to do was to set EnableCaching to false.

<asp:SqlDataSource ID="SqlDataSourceTV" runat="server" EnableCaching="false" DataSourceMode ="DataSet" ConnectionString="<%$ ConnectionStrings:Commercial %>"> </asp:SqlDataSource>
duwen_blade
  • 33
  • 1
  • 1
  • 7