Populating a list with data from a database table in InfoPath2007

D

Dibs

Hi Friends,

I got a textbox, a listbox and a button in an InfoPath 2007 form. The user
enters his ID in the textbox and clicks the button. I need to fetch all the
subjects, he has enrolled for, from a database table and populate the
listbox with the data one by one.
Obviously the query will be a parameterized query based on the ID that is
entered in the textbox. How to do this..?

Any suggestions are welcome...

Cheers,
Dibs
 
C

Clay Fox

There are a couple ways to do this.

You can add a secondary data connection to your form that will retrieve all
of the data in the table and you can filter it to display just the
information you want. However there is a performance issue since you cannot
truly query the table with a direct connection to the DB.

You can create a database form from scratch which will allow you to query
and submit to one table but this may not be what you are really looking for
since the data is not the primary.

Use webservices such as those available in the Database Accelerator which
gives you the ability to query and submit to multiple tables along with a lot
of other features such as Active Directory information to ID the Form user.
http://www.qdabra.com
--
Thanks

Clay Fox

Qdabra Software
http://www.qdabra.com

InfoPathDev.Com
The Largest InfoPath Forum in the World
http://www.infopathdev.com
 
D

Dibs

Thanks for the reply Clay...
I could have done that but I also have to do some custom processing of the
data that is returned from the database which is only possible through code
i.e in the button click event in the VSTA. So, the steps I need to follow
will be...
1. Fetch the data from the database
2. Filter the data based on the parameter
3. Apply some custom processing and calculation
4. Add the data to the listbox. The list box can be replaced by a repeating
table.

What I can't figure out is step 4. I can set a text box's value from code
using :
xNavMain.SelectSingleNode("/my:myFields/my:txtBox",
this.NamespaceManager).SetValue(string);

But I can't set values for a list box from code...

Will you be able to help me out..? It will be a browser-enabled form...
 
S

S.Y.M. Wong-A-Ton

A list box works on the same way as a drop-down list box. What you have to do
is bind it to a repeating group, either in your main data source or a
secondary data source, and then add child nodes to the group using
AppendChild(). The group will be filled with the items and they will then
appear in your list.

There are many approaches possible to this issue. I once wrote an article to
fill a drop-down list box
(http://enterprise-solutions.swits.n...populate-drop-down-list-box-infopath-2007.htm).
The concept to fill a list box is the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top