hello, i'm have a payment form and a listview in this form. i'm adding about 3 item in the listview, so it has 3 row. but how can i insert the items in one of the column into database.

for example for listview

id item netmount
123 Stock1 113.00
231 stock2 200.00
321 stock3 100.00

my database column after inserted data

item1 item2 item3
stock1 stock2 stock3


can someone help me?

Recommended Answers

All 6 Replies

obtain values from the listview and insert them directly to the table using a for loop
e.g....
for i = 0 to listview1.items.count - 1
id = listview1.item(i, 0).text
item = listview1.item(i, 1).text
netmount = listview1.item(i, 2).text
query = "INSERT INTO <table_name> values(<the values here above>);"
next

... assuming you've already connected to the database

is id = "123" , item = "Stock1" , netmount = "113.00"
or id = "stock1" , item = "stock2" , netmount = "stock3?

i need to insert items from column "item" only.

please help.

Still use the for loop above, but remove the items u dont need to save. If u want to insert all of them in one row, then consider an update statement when i > 0

brian, can you give me the code?
i'm newbie actually.

'this code will help you to insert the data one item per row; unless otherwise, it should solve your problem
for i = 0 to listview1.items.count - 1
'id = listview1.item(i, 0).text #i meant you remove this...
item = listview1.item(i, 1).text
'netmount = listview1.item(i, 2).text # ...and this
query = "INSERT INTO <table_name> values(<the values here above>);"
next

If this doesn't work, please post your code here~!

'this code will help you to insert the data one item per row; unless otherwise, it should solve your problem
for i = 0 to listview1.items.count - 1
'id = listview1.item(i, 0).text #i meant you remove this...
item = listview1.item(i, 1).text
'netmount = listview1.item(i, 2).text # ...and this
query = "INSERT INTO <table_name> values(<the values here above>);"
next

If this doesn't work, please post your code here~!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.