Im using Anychart and I pretend to update the point value automatically after the Table1 is update in database.
Well Im new in ASP.net , and I expect that the javascript function should update the variable every time I update the table "Table1" in my database, what it does it updates the value just once.
I will apreciate your help.
//////////////////////////////////////////////
the code behind
Well Im new in ASP.net , and I expect that the javascript function should update the variable every time I update the table "Table1" in my database, what it does it updates the value just once.
I will apreciate your help.
Code:
<script type="text/javascript" language="javascript" >
//<![CDATA[
var chart = new AnyChart('../anychart_files/swf/AnyChart.swf');
chart.setXMLFile('TemperatureXMLFile.xml');
chart.write('container');
var airtempjs = "<%=airtempcs%>" // The string airtempcs is defined in codebehind
function update() {
chart.updatePointData("Thermometer", "Temp", { value: (airtempjs) });
}
setInterval(update, 400);
//]]>
</script>
the code behind
Code:
public string airtempcs;
protected void Page_Load(object sender, EventArgs e)
{
//Create the command and the Connections Objects
string connectionString = ConfigurationManager.ConnectionStrings["ChartTestConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("SELECT AirTemp FROM Table1", con);
//Open the connection and get the DataReader
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
airtempcs = reader.GetDouble(0).ToString();
}
reader.Close();
con.Close();
}
Comment