How can I add items in a Listbox into an SQL table??
Printable View
How can I add items in a Listbox into an SQL table??
you can use a for loop and an sql statement executed in ado for that purpose
VB Code:
if List1.ListCount > 0 then Dim a as Long for a = 0 to List1.ListCount - 1 cn.execute "insert into statement here to insert the data from the listbox to the db" Next End If
This doesn't seem to work
Actually I hav to add the raw materails used in a product
I'm doing something as follows:
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List(lstRM.ListIndex)
rs.Update
I know this code is wrong.
Please suggest some code that is appropriate with this method
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List(lstRM.ListIndex)
rs.Update
Thx..
just put this into a loop
VB Code:
For i = 0 To lstRM.ListCount -1 rs.AddNew rs!prod_name = txtname rs!raw material = lstRM.List (i) rs.Update Next
just give a try and post if anything else
For i = 0 To lstRM.ListCount -1
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List (i)
rs.Update
Next
this is generating an error '3265'
Sorry I solved that error.
But this method only seems to add the last item in the list.
Is there any way of adding all the items in the list into the table??
Thx every1 for ur help.
I found the solution.
I thought I should post it.
Dim rm As String
Dim a as Integer
For a = 0 To list1.ListCount-1
rm = rm & list1.List(a)
Next
rs!RM = rm
rs.Update