Click here to Skip to main content
15,889,833 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to build acticle writing control. Pin
Hristiyan26-Jun-09 22:33
Hristiyan26-Jun-09 22:33 
QuestionUnable to set height and width in my web pages(aspx, master) if DOCTYPE is specified Pin
nainakarri26-Jun-09 21:18
nainakarri26-Jun-09 21:18 
QuestionServer Error... Pin
RajpootRohan26-Jun-09 20:26
professionalRajpootRohan26-Jun-09 20:26 
AnswerRe: Server Error... Pin
Christian Graus26-Jun-09 21:03
protectorChristian Graus26-Jun-09 21:03 
GeneralRe: Server Error... Pin
RajpootRohan26-Jun-09 21:14
professionalRajpootRohan26-Jun-09 21:14 
GeneralRe: Server Error... Pin
Christian Graus26-Jun-09 21:20
protectorChristian Graus26-Jun-09 21:20 
AnswerRe: Server Error... Pin
dan!sh 26-Jun-09 21:16
professional dan!sh 26-Jun-09 21:16 
GeneralRe: Server Error... Pin
RajpootRohan26-Jun-09 21:48
professionalRajpootRohan26-Jun-09 21:48 
d@nish wrote:
Show some code how you are trying to access the table. That would help.


I changed the table name "STATIC" to "STATICDATA" and the code is:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
        BenefitsData();
        WelcomeData();
        list_of_courses();
        Latest_News();
        }
    }
    public void WelcomeData()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "select Welcome from dbo.STATICDATA";
        cmd.Connection.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            string welcome_text = rdr["welcome"].ToString();
            LblWelcomeText.Text = welcome_text;
        }
        cmd.Connection.Close();
    }

    public void BenefitsData()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "select Benefits from dbo.STATICDATA";
        cmd.Connection.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            string benefits_text = rdr["Benefits"].ToString();
            LblBenefits.Text = benefits_text;
        }
        cmd.Connection.Close();
    }

    public void Latest_News()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "select top 1 headline,submit_time from dbo.NEWS order by submit_time desc";
        cmd.Connection.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            string head = rdr["headline"].ToString();
            LblMainHeadline.Text = head;
            string dat = rdr["submit_time"].ToString();
            LblDate.Text = dat;
        }
        cmd.Connection.Close();
    }

    public void list_of_courses()
    {

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "select course_name,pdf_file from dbo.COURSES";
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        con.Open();
        sda.Fill(dt);
        DataView dview = dt.DefaultView;
        DataCourses.DataSource = dview;
        DataCourses.DataBind();
        con.Close();
    }
}


cheers,
sneha

GeneralRe: Server Error... Pin
Christian Graus26-Jun-09 22:02
protectorChristian Graus26-Jun-09 22:02 
GeneralRe: Server Error... Pin
r a m e s h26-Jun-09 22:14
r a m e s h26-Jun-09 22:14 
AnswerRe: Server Error... Pin
Vimalsoft(Pty) Ltd26-Jun-09 23:40
professionalVimalsoft(Pty) Ltd26-Jun-09 23:40 
AnswerRe: Server Error... Pin
RajpootRohan27-Jun-09 1:09
professionalRajpootRohan27-Jun-09 1:09 
Questionconnectionstring for MySql using asp.net Pin
estatekhoj26-Jun-09 20:09
estatekhoj26-Jun-09 20:09 
AnswerRe: connectionstring for MySql using asp.net Pin
Christian Graus26-Jun-09 20:15
protectorChristian Graus26-Jun-09 20:15 
AnswerRe: connectionstring for MySql using asp.net Pin
Abhijit Jana26-Jun-09 21:49
professionalAbhijit Jana26-Jun-09 21:49 
GeneralRe: connectionstring for MySql using asp.net Pin
Christian Graus26-Jun-09 23:39
protectorChristian Graus26-Jun-09 23:39 
QuestionConvert CrystalReport to Sqlserver Reporting server Pin
ptvce26-Jun-09 20:05
ptvce26-Jun-09 20:05 
AnswerRe: Convert CrystalReport to Sqlserver Reporting server Pin
r a m e s h27-Jun-09 0:28
r a m e s h27-Jun-09 0:28 
QuestionHardware Cofiguration and Software details Pin
raushan_926-Jun-09 19:55
raushan_926-Jun-09 19:55 
AnswerRe: Hardware Cofiguration and Software details Pin
Christian Graus26-Jun-09 20:16
protectorChristian Graus26-Jun-09 20:16 
GeneralRe: Hardware Cofiguration and Software details Pin
raushan_926-Jun-09 20:28
raushan_926-Jun-09 20:28 
GeneralRe: Hardware Cofiguration and Software details Pin
Christian Graus26-Jun-09 21:01
protectorChristian Graus26-Jun-09 21:01 
QuestionSet Focus from html textbox to html listbox..... Pin
dayakar_dn26-Jun-09 19:54
dayakar_dn26-Jun-09 19:54 
AnswerRe: Set Focus from html textbox to html listbox..... Pin
Christian Graus26-Jun-09 20:17
protectorChristian Graus26-Jun-09 20:17 
QuestionHow to get confirmation from user when clicking on Next button in Wizard Control? Pin
meeram39526-Jun-09 19:54
meeram39526-Jun-09 19:54 

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.