TexG Posted April 21, 2003 Posted April 21, 2003 I am adding to a listview with no problem but when I try and add a field of type "text" from access database with: ListView1.Items(i).SubItems.Add(myReader("description")) I get the following error! An unhandled exception of type 'System.Reflection.AmbiguousMatchException' occurred in microsoft.visualbasic.dll Additional information: No accessible overloaded 'ListViewSubItemCollection.Add' can be called without a narrowing conversion. what does that mean and how can i fix it? Thanks Quote
*Experts* Nerseus Posted April 21, 2003 *Experts* Posted April 21, 2003 Try this: ListView1.Items(i).SubItems.Add(myReader("description").ToString()) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
TexG Posted April 21, 2003 Author Posted April 21, 2003 I had to put it on all of the myRead items but it worked like a charm. Thanks Nerseus Your the man!!!!!!!!!! Quote
*Experts* Nerseus Posted April 21, 2003 *Experts* Posted April 21, 2003 Remember that every column in a DataSet/DataReader is an object. That object can be pretty much any type. Luckily, all objects have the ToString() method. If your column might be NULL (NULL in your database, System.DBNull.Value in code), you may want to trap for that and use "string.Empty" instead of column.ToString(). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
TexG Posted April 21, 2003 Author Posted April 21, 2003 Ill check that out. If i run in to any problems ill give ya a ring. thanks again Quote
*Experts* Nerseus Posted April 21, 2003 *Experts* Posted April 21, 2003 I'll try to answer it before it's asked :) If myReader("description") = System.DBNull.Value Then ListView1.Items(i).SubItems.Add(string.Empty) Else ListView1.Items(i).SubItems.Add(myReader("description").ToString()) End If Of course, if the description is null, you may not want to add it at all. I'm just showing how you could detect null and add an empty string instead. By the way, that code may not compile - I typed it by hand (not in the IDE) but it should be close -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
TexG Posted April 21, 2003 Author Posted April 21, 2003 ok will try it out and let you know. Fighting anther problem trying to print a listview contance. wish me luck. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.