473,549 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fill combo box with data from database

This is a table created in ms sql:

create table categories
(
CategoryID int IDENTITY,
CategoryDescrip tion varchar(30),
ParentCategoryI D int
);

This is a stored procedure created in ms sql:

create procedure usp_retrieveCat egories
AS SET NOCOUNT ON

SELECT CategoryID, CategoryDescrip tion FROM categories WHERE
CategoryID >= 1

Return
GO
This is a code to fill my combo box on my .asp page:

<select name="select" class="TextFiel d1">
<%
openDB()

objConn.usp_ret rieveCategories , rs

while not rs.eof
%>
<option
value=<%=rs("Ca tegoryID")%>><% =rs("CategoryDe scription")%>
<%
wend

CloseDB()
%>
</select>
I am getting an error:
Error Type:
ADODB.Connectio n (0x800A0E7C)
Parameter object is improperly defined. Inconsistent or incomplete
information was provided.
The error points to objConn.usp_ret rieveCategories , rs

How do I solve the problem?

Your help is kindly appreciated.

Regards

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***
Jul 22 '05 #1
4 6326
1. Why the WHERE clause?

Try this:

openDB()
Set rs = objConn.Execute ("EXEC usp_retrieveCat egories")

Ray at work
"Eugene Anthony" <so***********@ yahoo.com> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
This is a table created in ms sql:

create table categories
(
CategoryID int IDENTITY,
CategoryDescrip tion varchar(30),
ParentCategoryI D int
);

This is a stored procedure created in ms sql:

create procedure usp_retrieveCat egories
AS SET NOCOUNT ON

SELECT CategoryID, CategoryDescrip tion FROM categories WHERE
CategoryID >= 1

Return
GO
This is a code to fill my combo box on my .asp page:

<select name="select" class="TextFiel d1">
<%
openDB()

objConn.usp_ret rieveCategories , rs

while not rs.eof
%>
<option
value=<%=rs("Ca tegoryID")%>><% =rs("CategoryDe scription")%>
<%
wend

CloseDB()
%>
</select>
I am getting an error:
Error Type:
ADODB.Connectio n (0x800A0E7C)
Parameter object is improperly defined. Inconsistent or incomplete
information was provided.
The error points to objConn.usp_ret rieveCategories , rs

How do I solve the problem?

Your help is kindly appreciated.

Regards

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***

Jul 22 '05 #2
Where do you define rs?

Here is how I would write it.

<select name="select" class="TextFiel d1">
<%
openDB()
set rs = objConn.Execute ("usp_retrieveC ategories")
do while not rs.eof
response.write "<option value='" & rs(0) & "'>" & rs(1)
rs.movenext ' <---- important step!
loop
closeDB()
%>
</select>

If this is not the only database thing you are doing on this page, I
strongly recommend against opening and closing the connection every time.
It will be more efficient to open the object once (just before the *first*
time you need it), and close it just after the last time you use it.

A

I am sure Bob will show you how to properly define rs before stuffing a
resultset into it.

"Eugene Anthony" <so***********@ yahoo.com> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
This is a table created in ms sql:

create table categories
(
CategoryID int IDENTITY,
CategoryDescrip tion varchar(30),
ParentCategoryI D int
);

This is a stored procedure created in ms sql:

create procedure usp_retrieveCat egories
AS SET NOCOUNT ON

SELECT CategoryID, CategoryDescrip tion FROM categories WHERE
CategoryID >= 1

Return
GO
This is a code to fill my combo box on my .asp page:

<select name="select" class="TextFiel d1">
<%
openDB()

objConn.usp_ret rieveCategories , rs

while not rs.eof
%>
<option
value=<%=rs("Ca tegoryID")%>><% =rs("CategoryDe scription")%>
<%
wend

CloseDB()
%>
</select>
I am getting an error:
Error Type:
ADODB.Connectio n (0x800A0E7C)
Parameter object is improperly defined. Inconsistent or incomplete
information was provided.
The error points to objConn.usp_ret rieveCategories , rs

How do I solve the problem?

Your help is kindly appreciated.

Regards

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***

Jul 22 '05 #3
Eugene Anthony wrote:

objConn.usp_ret rieveCategories , rs


should be:

objConn.usp_ret rieveCategories rs

No comma

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #4
Eugene Anthony wrote:
openDB()

objConn.usp_ret rieveCategories , rs

And, as Aaron pointed out <grin>, the rs variable needs to be defined before
using it in this statement:

set rs=createobject ("adodb.records et")
objConn.usp_ret rieveCategories rs

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4703
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
2
2647
by: Joanne Lewis | last post by:
I am having a great deal of difficulty with a form. Basically, I would like to enter an account # and have the account #, patient first name, and patient last name automatically fill. The form Record Source table is "InitialInfoFromSW". I want to enter an account #, have it look in another table called "AS400 Imported Data", and...
9
2004
by: Mike McGee | last post by:
I am new to database apps, but I am making a db with access 2002. Here is what I have and what I would like for it to do. tblCustomers = holds customer info (Name, Address, City, State, Zip, Phone) tblzips = holds ( Zip codes, City, State, County, Country) tblzips ID Zipcode City State County Country
2
6935
by: Jeremy Dillinger | last post by:
I have a program setup to pull data from a database. My database table has things such as (category, Item, price, etc.) In my program I want to have multiple list boxes that will have a pull down list of different categories. The category is stored as a number and the item is stored as a string. Also once the item is picked from the list I...
4
1433
by: K R Lal | last post by:
Hello all, how can i fill the data to combo box from dataset please help me. regards lal
18
20211
by: Vayse | last post by:
Has anyone an example of filling a combo box with a data reader? Thanks Vayse
0
1542
by: CanFlightSim | last post by:
I use combo boxes and a great little piece of code to fill a form with a record set. For example I want to search by Lastname and fill the form or by company and fill the form, I will start typing the last name in a combo and it fills ... press enter and the form fields load. 'Find the record that matches the pick. Private Sub...
1
2346
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific letter. If I edit the description for one record, it edits the same for all records in which I've applied the same autofill (auto lookup). I'm set up...
4
2355
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. The idea behind the database is for a user to search/ select desired information in any kind of combination between the 4 combo boxes. Then the user...
0
7461
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7971
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7491
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5381
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3509
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1068
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.