ListView

  • Thread starter news.telusplanet.net
  • Start date
N

news.telusplanet.net

I am trying to populate a list view using this code

if the reader returns this data when querying for all workordernumbers
starting with 98

workordernumber date firstname
9808 2004-09-08 Travis
9889 2001-09-12 Lane
9806 2004-09-03 Geoff

the list view only displays the workordernumbers and not the dates or
firstnames

*****************************************
string mySelectQuery = "SELECT workordernumber, date, firstname FROM
customers WHERE workordernumber LIKE " + "\'"
+ workordernumber.Text + "%\'" + "";

OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection);
OdbcDataAdapter da = new OdbcDataAdapter (mySelectQuery,myConnection);

string [] tempstorage = new string []{};
//Open The Connection for Data Reader
myConnection.Open();

myDataReader = myCommand.ExecuteReader();
while (myDataReader.Read())
{
if (string.Compare(myConnection.Driver,"myodbc3.dll") == 0)
{
string[] myItems = new
string[]{myDataReader.GetString(0),myDataReader.GetString(1),myDataReader.Ge
tString(2)};
tempstorage = myItems;
// insert all the items into the listview at the last available
row
ListViewItem lvi = new ListViewItem(tempstorage);
DatabaseListView.Items.Add(lvi);
}
}
myConnection.Close();
****************************************



I have initialized the listview with this code
*************************************************
public void StartListView()
{
ColumnHeader header1 = this.DatabaseListView.Columns.Add("workordernumber",
10*Convert.ToInt32(DatabaseListView.Font.SizeInPoints),
HorizontalAlignment.Center);
ColumnHeader header2 = this.DatabaseListView.Columns.Add("date",
20*Convert.ToInt32(DatabaseListView.Font.SizeInPoints),
HorizontalAlignment.Center);
ColumnHeader header3 = this.DatabaseListView.Columns.Add("firstname",
20*Convert.ToInt32(DatabaseListView.Font.SizeInPoints),
HorizontalAlignment.Center );
}
*************************************************

I have also noted that I cannot change the listview properties to REPORT
instead of LIST


HELP

Thankyou for your time

Travis
(e-mail address removed)
 
N

news.telusplanet.net

Okay I fugured it out...
I changed the listView Properties to Deatails and now the heading all appear
and it fills inthe data
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ODBC.net 3
String Array with Dynamic Size 2

Top