April 20, 201016 yr Hi all, I am developing a simple webform to display data from database, i would like to display the winners voting with every 5seconds refresh. Before we come to the refresh, i am now unable to display the data in the webform. I doubt i had make a mistake in my coding, hope you can help me to solve the problem. I had created an ".aspx" and ".aspx.cs", using mecromedia dreamweaver 8, does my ".aspx.cs" pass function to ".aspx" successfully? Or my code inside ".aspx.cs" are wrong? Coding for .aspx <%@ Page language="c#" Codebehind="WinnerList.aspx.cs" AutoEventWireup="false" Inherits="testisms.WinnerList" %> <meta http-equiv="refresh" content="3"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <style type="text/css"> <!-- .STYLE2 {font-size: 36px} --> </style> <HEAD> <title>WinnerList</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body> <form action="frmdisplay" method="post" runat="server"> <label><span>Winner 1:</span></label> <span> <asp:Label id="lblw1display" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" ForeColor="DarkGoldenrod"></asp:Label> <br> <br> <label>Winner 2:</label> <asp:Label id="lblw2display" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" ForeColor="DarkGoldenrod"></asp:Label> <br> <br> <label>Winner 3:</label> <asp:Label id="lblw3display" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" ForeColor="DarkGoldenrod"></asp:Label> </span> </form> </body> </HTML> Coding for .aspx.cs using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.OleDb; namespace testisms { /// <summary> /// Summary description for WinnerList. /// </summary> public class WinnerList : System.Web.UI.Page { protected System.Web.UI.WebControls.Label lblw1display; protected System.Web.UI.WebControls.Label lblw2display; protected System.Web.UI.WebControls.Label lblw3display; private void Page_Load(object sender, System.EventArgs e) { lblw1display.visible = true; lblw2display.visible = true; lblw3display.visible = true; // Create connection string variable. Modify the "Data Source" // parameter as appropriate for your environment. String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("C:\Program Files\MySQL\data\vgsmdb\loglog.MYD"); // Create connection object by using the preceding connection string. OleDbConnection objConn = new OleDbConnection(sConnectionString); objConn.Open(); // Create new OleDbCommand to return data from worksheet. OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM loglog", objConn); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); objAdapter1.SelectCommand = objCmdSelect; DataSet objDataset1 = new DataSet(); objAdapter1.Fill(objDataset1, "XLData"); private void display() { int sqlw1 = ("SELECT COUNT('CONTENT') FROM LOGLOG" + "WHERE CONTENT = '1'"); int sqlw2 = ("SELECT COUNT('CONTENT') FROM LOGLOG" + "WHERE CONTENT = '2'"); int sqlw3 = ("SELECT COUNT('CONTENT') FROM LOGLOG" + "WHERE CONTENT = '3'"); lblw1display.text = sqlw1 lblw1display.text = sqlw2 lblw1display.text = sqlw3 } display() // Clean up objects. objConn.Close(); }
Create an account or sign in to comment