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
XMarshall XMarshall
NA
3
0
ListView - Unable to view data in the control
Dec 21 2008 4:16 AM
Hi,
I am an newbie in C#. I am entering data in an ListView control after retrieving data from the SQL Sever database using OleDbConnection, OleDbCommand and OleDbDataReader classes. The code is given below. Pls let me know where I am going wrong?? I am using VS2005 and the code does not throws any exceptions, also the data is getting retrieved correctly, but only not being populated in the ListView control.
public void DisplayRecords(OleDbDataReader rows, string str)
{
listViewDetails.Clear();
try
{
if (str.CompareTo("DETAILS") == 0)
{
int nCount = rows.FieldCount;
//nCount returns 7 (fields)
ListViewItem lvi = new ListViewItem();
for (int i = 0; i < nCount; i++)
{ //Adding colums headers
ColumnHeader header = new ColumnHeader();
header.Width = 100;
header.Text = rows.GetName(i);
listViewDetails.Columns.Add(header.Text);
}
//Data population
while (rows.Read() == true)
{
lvi = listViewDetails.Items.Add(rows.GetValue(0).ToString());
for (int i = 1; i < nCount; i++)
{
lvi.SubItems.Add(rows.GetValue(i).ToString());
}
}
}
}
Reply
Answers (
3
)
Capture photo from webcam
How to convert Object type to DataTime?