1.11M Members

insert data from listview into database

 
0
 

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?

 
0
 

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

 
0
 

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.

 
0
 

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

 
0
 

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

 
0
 
'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~!

 
0
 
'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~!

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article