473,403 Members | 2,359 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,403 software developers and data experts.

How to pass listbox values into an sql statement

Hello everyone!
I need some help. I'm trying to create an SQL Insert statement in VB and I need to pass the value of the listbox as fieldnames. It goes like this:
Expand|Select|Wrap|Line Numbers
  1.   sql = "Insert into TableName (List1.List(0), List1.List(1),.......) Values
  2.            rs.Fields(0),rs.Fields(1),....)
Thanks.
Feb 12 '07 #1
1 2551
Killer42
8,435 Expert 8TB
Hello everyone!
I need some help. I'm trying to create an SQL Insert statement in VB and I need to pass the value of the listbox as fieldnames. It goes like this:
Expand|Select|Wrap|Line Numbers
  1.   sql = "Insert into TableName (List1.List(0), List1.List(1),.......) Values
  2.            rs.Fields(0),rs.Fields(1),....)
The SQL interpreter doesn't know anything about VB listboxes. What you need to do is get the values and concatenate them into the string. For example...
Expand|Select|Wrap|Line Numbers
  1. sql = "Insert into TableName  (" _
  2.     & List1.List(0) _
  3.     & "," _
  4.     & List1.List(1) _
  5.     ...
  6.     & ") Values (" _
  7.     & rs.Fields(0) _
  8.     & "," _
  9.     & rs.Fields(1) _
  10.     & ","
  11.     ...
Feb 12 '07 #2

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

Similar topics

1
by: Jeff Thur | last post by:
I have a listbox with all the US States. I need the user to select multiple States from that listbox and pass them on as parameters to a SQL Stored Procedure that will give them a count of all the...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
2
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
3
by: Paul W | last post by:
I am populating listbox with a datreader. DateReader sqlcommand is dynamic, based on several user selections Listbox DataValueField is set to the tables primary key Listbox DataTextField is...
4
by: Justin | last post by:
I have a web form that allow the user to add dates to a listbox control and they are also added to an arraylist at the same time but I do not know how to select all the rows into one string then...
13
by: Larry Woods | last post by:
I am creating a "from-to" set of listboxes where the "left" listbox had a list of values and I want to be able to select these values, 1 at a time, and move them into a "right" listbox, removing...
3
by: Richard Albrecht | last post by:
I have been trying to figure out for days on how to read values from a Bound ListBox. The listBox gets the values from an Access Table. I can read values fine for Non-Bound ListBoxes, But the...
4
by: Seok Bee | last post by:
Dear Experts, I am having 1 listbox control in my web form and trying to retrieve the items and load into it. I want to list out those uploaded files into the database and list out in the...
1
by: nasirmajor | last post by:
i have a databound listbox that has a multilple selection made to true. when user select multiple values in listbox and clicks button i want them to show the results in the datagrid on the same...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.