TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
narasiman rao
NA
519
768.5k
Displaying the database record using datatbale in c#
Dec 22 2015 10:25 PM
i am displaying the database record using datatable
In LatestNewsMaster table record as follows
id Subject Link Active
1 Defect Mail defectmail.aspx A
2 Accounts Fee accountsfee.aspx A
3 Latestenews page Latestnews.aspx A
My code as follows
string constr = ConfigurationManager.ConnectionStrings["Reception2_DB"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("select Link from LatestNewsMaster where active <> 'd'"))
{
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
label1.Text = dt.Rows[0][0].ToString().Trim();
return dt;
}
}
}
But when i run in label dsiplaying only firt recrod defectmail.aspx in the label1. not displaying all the three link records from the database.
from my above code what is the mistake i made.
Reply
Answers (
2
)
How to connect to Portable devices programmatically using C#
How to read a column as combination of string and int in exc