vb.net - Why is this VB code failing on me? -
hers form code:
imports techsupportdata public class frmopenincidents private sub frmopenincidents_load(byval sender system.object, byval e system.eventargs) handles mybase.load dim incidentlist list(of incident) try incidentlist = incidentdb.getincidents if incidentlist.count > 0 dim incident incident integer = 0 incidentlist.count - 1 incident = incidentlist(i) lvincidents.items.add(incident.productcode) lvincidents.items(i).subitems.add(incident.dateopened) lvincidents.items(i).subitems.add(incident.customerid) lvincidents.items(i).subitems.add(incident.techid) lvincidents.items(i).subitems.add(incident.title) next else messagebox.show("all incidents taken care of") me.close() end if catch ex exception messagebox.show(ex.message, ex.gettype.tostring) me.close() end try end sub end class
and heres class working with:
imports system.data.sqlclient public class incidentdb public shared function getincidents() list(of incidentdb) dim incidentlist new list(of incidentdb) dim connection sqlconnection = techsupportdb.getconnection dim selectstatement string _ = "select customerid, productcode, techid, dateopened, title" _ & "from(incidents)" _ & "where dateclosed null" dim selectcommand new sqlcommand(selectstatement, connection) try connection.open() dim reader sqldatareader = selectcommand.executereader() dim incident incident while reader.read incident = new incident incident.incidentid = reader("incidentid").tostring incident.customerid = reader("customerid").tostring incident.productcode = reader("productcode").tostring incident.dateopened = reader("dateopened").tostring loop reader.close() catch ex exception throw ex connection.close() end try return incidentlist end function end class
heres error i'm getting visual studio:
error 1 value of type 'system.collections.generic.list(of techsupportdata.incidentdb)' cannot converted 'system.collections.generic.list(of techsupportdata.incident)'. c:\users\cody\desktop\school\current\itech4269 visual basic\assignment2codystewart\assignment2codysteawrt\assignment2codysteawrt\frmopenincidents.vb 8 28 assignment2codysteawrt
any guidance or suggestions appreciated, lot.
in class frmopenincidents you've defined incidentlist
list of incidents:
dim incidentlist list(of incident)
then set it:
incidentlist = incidentdb.getincidents
but incidentdb method defined returning list of incident*db*:
public shared function getincidents() list(of incidentdb)
solution might change first definition this?
dim incidentlist list(of incidentdb)
you need choose name class - incident or incidentdb - , use consistently rid of similar errors.
Comments
Post a Comment