Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
Displaying the database record using datatbale in c#
narasiman rao
9y
513
1
Reply
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.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to connect to Portable devices programmatically using C#
How to read a column as combination of string and int in exc