Fetch data from the database and place it in a marquee

1. First we should take the marquee tag in the source of our web form(Page.aspx) page like this:

<marquee direction="up" onmouseover="this.start()" onmouseout="this.stop()"
scrolldelay="300? style="height: 213px">
<asp:Literal ID="lt1? runat="server"></asp:Literal></marquee>

Note:-> literal to show the database values in the marquee

2. In Database:

My Database Name: db2

Create a table:

create table news1
(
 
id int identity(1,1),
headings varchar(50)
);

3. Page.aspx coding:

using System.Data.SqlClient;

SqlConnection conn1 = new SqlConnection("data source=AB\\SQLEXPRESS;initial catalog=db2;integrated security=true");

SqlDataAdapter da1 = new SqlDataAdapter("select * from news1?, conn1);
DataSet ds1 = new DataSet();
da1.Fill(ds1, "news1?);
string s1;
s1 = "<table><tr><td><a href=Default3.aspx style=font-family: fantasy; font-size: small; font-weight:bold; font-style: normal; color: #660066>";
 
s1 += ds1.Tables["news1"].Rows[0][1].ToString();
s1 += "</a></td>";
s1 += "<br/>";
s1 += "<tr><td><a href=Default2.aspx style=color: #9966FF; font-weight: bold;>";
s1 += ds1.Tables["news1"].Rows[1][1].ToString();
s1 += "</a></td></table>";
lt1.Text = s1.ToString();


Similar Articles