473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Loop listbox and insert

OuTCasT
374 256MB
I have a listbox on my form that has items that the user has chosen, i need to loop through the listbox and get the values and insert them into a sql table.

Can anyone hlp?
Jan 26 '09 #1
2 1917
debasisdas
8,127 Expert 4TB
use the index of items selected.
Jan 27 '09 #2
OuTCasT
374 256MB
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim i As Integer
  3. Dim strString As String
  4. For i = 0 To ListBox2.Items.Count - 1
  5. strString = ListBox2.Items(i)
  6. MsgBox(strString)
  7. sqlCon = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=test;Integrated Security=True")
  8. sqlCon.Open()
  9. sqlCommand = New SqlCommand("insert into employee(EarningLineNO,EmployeeCode)values('" & strString & "','001')", sqlCon)
  10. sqlCommand.ExecuteNonQuery()
  11. sqlCon.Close()
  12. Next i
  13.  
Jan 27 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Andrew | last post by:
Hi I just started learning wxPython I wanted to know how I could do this in wxPython self.listbox.delete(0, END) for item in self.results: self.listbox.insert(END, item)
1
by: Ebba Cecilia Ovesdotter Alm | last post by:
Hello, I'm learning how to use the Tkinter module. I would like to use an element similar to a drop-down form, where the user can select one option out of many. I thought that a Listbox item...
2
by: Harlin Seritt | last post by:
Whenever I set up something similar: vals = for v in vals: listbox.inset(END, v) I notice that when this listbox is displayed, there is never a default value. How can I make sure that one...
1
by: Harlin Seritt | last post by:
I am trying to poll selections from a listbox but can't seem to get it to work correctly. class pollstuff: def __init__(self, master): self.listbox = Listbox(master) self.listbox.pack() ...
3
by: Gustavo Randich | last post by:
The following seems to be a bug. The execution returns rows 1,2. It should return 1,1. In fact, if I run the code within a stored procedure alone (not in a trigger), the loop doesn't overwrite the...
0
by: Banu | last post by:
I have 2 listboxes, one with all application available, and the other with the selected applications by user (dual listbox). I have 3 tables (incident,application and ListApplication) ...
0
by: Banu | last post by:
I have 2 listboxes, one with all application available, and the other with the selected applications by user (dual listbox). I have 3 tables (incident,application and ListApplication) ...
0
by: Avenue | last post by:
Hello Everyone, I am brand new to T-SQL and have come across an interesting situation recently - I have a database which contains a table with a single column. On occasion I need to populate...
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.