Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have a doubt that he needed to see clarified. I have a marquee that loads text from a database but all I get is a recording and I need all the records, any idea how to make the marquee load all records from the database?
Here is my code:
protected void Page_Load(object sender, EventArgs e)
   {

       SqlDataAdapter nextdays_da = new SqlDataAdapter("SELECT * FROM JANELA_CSD_INFO WHERE [Type]='Next days'", sqlconn);
       DataSet nextdays_ds = new DataSet();
       nextdays_da.Fill(nextdays_ds);
       DataTable nextdays_dt = nextdays_ds.Tables[0];
       NextDays = nextdays_dt.Rows.Count;
       if (NextDays == 0)
       {
           lt1.Text = "Não tem eventos próximos!";
       }
       if (NextDays == 1)
       {
           string assunto;
           sqlconn.Open();
           assunto = "SELECT Subject FROM JANELA_CSD_INFO WHERE Type='Next days' AND Status=1";
           SqlCommand assuntocmd = new SqlCommand(assunto, sqlconn);
           assuntocmd.ExecuteNonQuery();
           string ASSUNTO = ((string)assuntocmd.ExecuteScalar());
           string data;
           data = "SELECT Date FROM JANELA_CSD_INFO WHERE Type='Next days' AND Status=1 AND Subject='" + ASSUNTO + "'";
           SqlCommand datacmd = new SqlCommand(data, sqlconn);
           datacmd.ExecuteNonQuery();
           DateTime Data = Convert.ToDateTime(datacmd.ExecuteScalar());
           lt1.Text = ASSUNTO.ToString() + "*" + Data + "*";
           sqlconn.Close();
       }
       else if (NextDays > 1)
       {
           int Next_Days;
           sqlconn.Open();
           SqlDataAdapter NextDaysDA = new SqlDataAdapter("SELECT * FROM JANELA_CSD_INFO WHERE [Type]='Next days'", sqlconn);
           DataSet NextDaysDS = new DataSet();
           NextDaysDA.Fill(NextDaysDS);
           DataTable NextDaysDT = NextDaysDS.Tables[0];
           Next_Days = NextDaysDT.Rows.Count;
           Next_Days++;
           for (int i = 1; i < Next_Days; i++)
           {
               string assunto;
               assunto = "SELECT Subject FROM JANELA_CSD_INFO WHERE Type='Next days' AND Status=1";
               SqlCommand assuntocmd = new SqlCommand(assunto, sqlconn);
               assuntocmd.ExecuteNonQuery();
               string ASSUNTO = ((string)assuntocmd.ExecuteScalar());
               string data;
               data = "SELECT InitialDate FROM JANELA_CSD_INFO WHERE Type='Next days' AND Status=1 AND Subject='" + ASSUNTO + "'";
               SqlCommand datacmd = new SqlCommand(data, sqlconn);
               datacmd.ExecuteNonQuery();
               DateTime Data = Convert.ToDateTime(datacmd.ExecuteScalar());
               string data2;
               data2 = "SELECT ExpectedEndDate FROM JANELA_CSD_INFO WHERE Type='Next days' AND Status=1 AND Subject='" + ASSUNTO + "'";
               SqlCommand datacmd2 = new SqlCommand(data2, sqlconn);
               datacmd.ExecuteNonQuery();
               DateTime Data2 = Convert.ToDateTime(datacmd.ExecuteScalar());
               lt1.Text = ASSUNTO.ToString() + "*" + Data + "-" + Data2 + "*";
           }
           sqlconn.Close();
       }
       if (!IsPostBack)
           BindGrid();
       else
           BindGrid();
   }
Posted
Comments
[no name] 9-Jul-12 12:33pm    
You have 7 queries going on here. Which one is give you the trouble?
Paulo Jorge Arteiro Soares 10-Jul-12 11:37am    
well now it loads the information but only appears the first one repeated :s imagine that i have 3 informations, in that case it shows 3 informations in marquee but all with the same text (the first one)
ZurdoDev 11-Jul-12 15:14pm    
What did you find is the issue when you debugged it?

Hi,
First of all, can't you execute your all 7 queries together using Stored Procedure[^]?
Where is the error? I am not able to find your error actually.

Not a problem. Try this:
HTML:
ASP.NET
<marquee><asp:label id="lblM" runat="server" xmlns:asp="#unknown" /></marquee>

CODE:
C#
//Take the value from database and store it in this string variable
string strMarque="Test"; //This will come from database. 

//Now set the marquee string to the lable inside marquee tag.
lblM.Text = strMarque;


--Amit
 
Share this answer
 
C#
protected void Page_Load(object sender, EventArgs e)
    {
        string abc = "hello world";
        Response.Write("<marquee>"+abc+"</marquee>");

    }
Now connect your abc string to the database's datareader object and execute. i.e..
sqldatareader dr = commandobject.executereader();
while (dr.read())
{
abc = dr[0].Tostring();
}

So it'll display what exactly is the data, as a marquee tag.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900