473,385 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to display data from a sql query in a listview?

hi i m using the following code
Expand|Select|Wrap|Line Numbers
  1.             SqlCommand cm2 = new SqlCommand("Select * from cand_details where cand_id='"+candid+"'",con);
  2.             dr = cm2.ExecuteReader();
  3.  
  4.  
this return the following :
Max Payne
timmy smoth
abc aha
and so on.............

I want to display this data in a list view i have on the form named listView1. How could i do this?
Dec 5 '10 #1
1 13634
Hi,
to add items to a list view (details view) :


Expand|Select|Wrap|Line Numbers
  1. while(dr.read())
  2. {
  3. listview1.Items.Add(dr[0].ToString());
  4.  
  5. // if your result have more that one column, use
  6.  
  7. listview1.Items.Add(dr[0].ToString()).SubItems.Add(dr[1].ToString());
  8. }
  9.  
Dec 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: 'bonehead | last post by:
Greetings, I'd like to figure out some syntax for retrieving the data from a table when I don't know all the of field names. What I do know are, the name of the table, the names of the primary...
5
by: yma | last post by:
Hello, I tried to display a column in MS Access 2000 nwind.mdb using 3 data controls. But I got "It is already opened exclusively by another user, or you need permission to view its data." I...
1
by: Mamatha | last post by:
Hi I was displayed some data in listview,but i want to display that data with some icons.I want like displaying icon on the left side of the data in the listview in VB.NET How to display icons...
2
by: Joe | last post by:
Anyone can suggest the best method of reading XML and adding data to ListView? Here is the xml data structure:: <xml> <site> <url>http://www.yahoo.com</url> <lastupdate></lastupdate>...
2
by: Jerry M. Gartner | last post by:
Greetings: As evident from a previous post, I am a php noob. I would like to display MySQL query results in an html table with one of the row values as a category and the rest of the data...
4
by: seth_hickel | last post by:
With other solutions I would get a recordset, read each record and display data by formating my html as I wanted to display values of each record. I am trying to display data in a three column...
7
by: nma | last post by:
Hi I'm trying to display data in a table list format but error message like this appear. What is wrong with the code? "Parse error: syntax error, unexpected '<' in C:\htdocs\...\MB2movieinfo.php...
1
by: mayang | last post by:
ca anyone help me the right coding in saving data from listview in vb6 to mySQL database...thanx in advance..
0
by: girishpatil | last post by:
how to modify listview subitems data manually.listview is filled with data from datab
0
by: dehneli | last post by:
I need to take data from listview, column by column, how cant I do that?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.