Start New Discussion within our Software Development Community

Sorry if there is a topic on this somewhere - i have been searching for awhile now no dice.


I'm upgrading a VB6 application to a vb.net 2008 application.

problem that's driving me nuts:

I fill a listview with a list of customer first & last names + number from a sql database, setting the listviews .tag as the customers id in the table.

in vb6 i did as follows:

if db_connect("select concat(first, ' ', last) as name, number from customer") = true then
do until adors.eof = true
with lstresults.listitems.add(,, adors.fields("name"))
.listsubitems.add,, adors.fields("number")
.tag = adors.fields("ID")
end with
adors.movenext
loop
end if
db_disconnect

then i would use the tag in various other areas if the customer was selected in the list view.

example: delete from customer where customer.ID = " & me.lstresults.selecteditem.tag


in .net 08 im doing the following:

Dim strInfo(1) As String
Dim lstNewItem As New ListViewItem
if DB_connect("select ID, concat(first, ' ', last) as name, number from customer") = true then
do until adors.eof = true
strinfo(0) = adors.fields("name").value
strinfo(1) = adors.fields("number").value
lstnewitem = new listviewitem(strinfo)
lstnewitem.tag = adors.fields("ID")
me.lstresults.items.add(lstnewitem)
adors.movenext
loop
end if
db_disconnect


i then try to call it as follows:
DELETE FROM customer where customer.ID = " & Me.lstResults.SelectedItems.Item(0).Tag

and i get an error that the tag can't be converted to a string, which i dont want it as a string and cdbl(.tag) says it cant be converted to a double..

basically its not pulling the ID for the .tag..

any help is appreciated, thanks!

lstNewItem.Tag = GlobData.ADORS.Fields("ID").Value

sorry - after typing it and reading it i realized that i was not putting the .value for the rs field..

its after 3:00
robert gulay is hanging out

This question has already been answered. Start a new discussion instead.