Hi
I want to add a dropdown Menu to my ACCESS database With ASP
Please Help Me
6 1915
Hi mbm2000,
To populate a drop down list from a database in ASP you can do the following: - <%
-
'Initialise the recordset and connection objects and open the connection
-
Dim oRS, oConn, sSQL
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open CONNECTION_STRING
-
Set oRS = Server.CreateObject ("ADODB.Recordset")
-
-
'Define the SQL used to query the database
-
sSQL = "SELECT ValueColumn, NameColumn FROM Table1 WHERE id = 1"
-
-
'Open the recordset
-
oRS.Open sSQL, oConn, 3
-
-
Response.Write "<select name='dropdown1'>"
-
-
'Loop through the recordset, writing an option for each row
-
Do Until oRS.EOF
-
Response.Write "<option value='" & oRS("ValueColumn") & ">"
-
Response.Write oRS("NameColumn")
-
Response.Write "</option>"
-
oRS.MoveNext
-
Loop
-
-
Response.Write "</select>"
-
-
'Destroy the objects
-
Set oRS = Nothing
-
oConn.Close
-
Set oConn = Nothing
-
%>
-
Does this help at all? Let me know.
Dr B
HI DR B
I want put this data to my access db
I use This code for Drop Down Menu -
<select size="1" name="star"value="<%= star %>">
-
<option selected>0</option>
-
<option>1</option>
-
<option>2</option>
-
<option>3</option>
-
<option>4</option>
-
<option>5</option>
-
<option>6</option>
-
<option>7</option>
-
</select>
-
and This Code For proccess -
<!--#include file="header.asp"-->
-
<%
-
On Error Resume Next
-
If Request.Cookies("user_logged_ID" & strSUnique) = Empty then Response.Redirect "register.asp"
-
If Request.Form("catID") = Empty Or Request.Form("subcatID") = Empty then Response.Redirect "post_new1.asp"
-
If isnotfree And Not Request.Cookies("allow_post" & strSUnique) = "True" then Response.Redirect "filter.asp?url=post_new1.asp&act=startOver"
-
-
If isnotfree then
-
set rs = objConn.Execute("SELECT credits FROM " & tablUPfx & "User WHERE userID = " & CLng(session("user_logged_ID" & strSUnique)) & ";")
-
If not rs.EOF then Session("user_logged_credit" & strSUnique) = FormatNumber(CCur(rs("credits")), 2)
-
rs.close
-
If CCur(Request.Cookies("final_price" & strSUnique)) > CCur(Session("user_logged_credit" & strSUnique)) Then
-
Response.Write strText_NotEnoughCredits
-
Response.End
-
End If
-
End If
-
-
-
Dim msg, star
-
setLocale server_locale
-
sdd = dd(objConn)
-
-
userID = CLng(Request.Cookies("user_logged_ID" & strSUnique))
-
postExpire = DateAdd("d", CLng(Request.Form("S1")), Now)
-
-
-
star = Request.form("star")
-
-
IP = Request.ServerVariables("REMOTE_ADDR")
-
adID = subcatID & RandomNumber & userID
-
adID = CStr(adID)
-
If moderate then active = 0: Else: active = 1
-
If len(subject) > 0 and Len(descr) > 0 Then
-
-
If not Request.Form("imgFile") = Empty then
-
img = sq(Request.Form("imgFile"))
-
imgArray = Split(img, sf)
-
For d = 0 to UBound(imgArray) - 1
-
imgName = Split(imgArray(d), "|")(0)
-
set rs = objConn.Execute("SELECT " & tablPfx & "Temp.tempimg FROM " & tablPfx & "Temp WHERE tempimg = '" & imgName & "';")
-
If Not rs.EOF then objConn.Execute("DELETE FROM " & tablPfx & "Temp WHERE tempimg = '" & imgName & "';")
-
rs.close
-
Next
-
End If
-
-
If isnotfree then
-
hotlist = Request.Cookies("hotlist" & strSUnique)
-
'If Len(img) > 0 then
-
userimglimit = Request.Cookies("image_limit" & strSUnique)
-
'Else: userimglimit = 0
-
'End If
-
Else
-
userimglimit = imagelimit
-
hotlist = 0
-
End If
-
-
For uo = 0 to 7
-
nextUserFormText = Request.Form("uO" & uo)
-
If Len(nextUserFormText) = 0 then nextUserFormText = Request.Form("uCOF" & uo)
-
strUserValues = strUserValues & ", '" & sq(HTMLEncode(nextUserFormText)) & "'"
-
strUserFields = strUserFields & ", " & "uopt" & uo + 1
-
Next
-
-
For o = 1 to 20
-
nextFormText = Request.Form("O" & o)
-
If Len(nextFormText) = 0 then nextFormText = Request.Form("COF" & o)
-
nextFormText = Replace(Replace(nextFormText, "<", "<"), ">", ">")
-
nextFormText = sq(HTMLEncode(nextFormText))
-
strCatValues = strCatValues & ", '" & nextFormText & "'"
-
strCatFields = strCatFields & ", " & "opt" & o
-
Next
-
-
strSQL = "INSERT INTO " & tablPfx & "Ads(adID, catID, scatID, cat3rdID, userID, pdate, edate, nick, city, subject, phone, web, images, webimage, body, status, IP, adcounter, hotlist, price"
-
strSQL = strSQL & strUserFields & strCatFields & ", userimagelimit) VALUES ('" & adID & "', " & catID & ", " & subcatID & ", " & cat3rdID & ", " & userID & ", " & sdd & PostPosted & sdd & ", " & sdd & postExpire & sdd & ", '" & nick & "', "
-
strSQL = strSQL & "'" & city & "', '" & subject & "', '" & phone & "', '" & URL & "', '" & img & "', '" & onlineImg & "', '" & descr & "', " & active & ", '" & IP & "', "
-
strSQL = strSQL & 0 & ", " & hotlist & ", '" & star & "', '" & price & "'" & strUserValues & strCatValues & ", " & userimglimit & ");"
-
-
objConn.Execute(strSQL)
-
-
Call updateUserPostData(userID, adID, price, "postnew")
-
-
If moderate then
-
Call getTemplate("New_Ad_Pending", email, Empty, nick, Empty, adID)
-
Else
-
Call UpdateList(True, catID, subcatID, cat3rdID)
-
Call getTemplate("New_Ad_Approved", email, Empty, nick, Empty, adID)
-
Application("cl_marquee" & strUnique) = Empty
-
Call matchAlerts(adID, catID, subcatID, cat3rdID, subject, descr)
-
End If
-
-
If IsCache then Call cacheAds(adID)
-
-
Call sendEmail(email, notify_email, uSubject, uBody)
-
Call getTemplate("Admin_Notify", email, Empty, nick, Empty, adID)
-
Call sendEmail(admin_email, notify_email, uSubject, uBody)
-
If isEvents then Call logEvent("New Ad", adID, subject, Empty, Empty, Empty)
-
-
Response.Cookies("user_logged_ID" & strSUnique) = Empty
-
Session("image_limit" & strSUnique) = Empty
-
Session("duration_limit" & strSUnique) = Empty
-
Session("hotlist" & strSUnique) = Empty
-
Session("allow_post" & strSUnique) = Empty
-
Session("final_price" & strSUnique) = Empty
-
session("Select_Category" & strSUnique) = Empty
-
session("Select_SubCategory" & strSUnique) = Empty
-
session("Select_CategoryID" & strSUnique) = Empty
-
session("Select_SubCategoryID" & strSUnique) = Empty
-
session("Select_3rdCategory" & strSUnique) = Empty
-
session("Select_3rdCategoryID" & strSUnique) = Empty
-
Session("Attach_Image" & strSUnique) = Empty
-
Set session("Attach_Image" & strSUnique) = Nothing
-
Set session("Temp_UserArray" & strSUnique) = Nothing
-
Session("Count_Image" & strSUnique) = Empty
-
-
-
Response.Write "<br><div align='center'>" & strText_Posted & " <b>" & email & "</b></div><br>"
-
If moderate then Response.Write "<div align='center'>" & strText_Posted1 & "</div><br>"
-
End If
-
%><!--#include file="tneval_footer.asp"--><!--#include file="footer.asp"-->
-
-
Thanks alot DR B
Sorry, I'm a bit confused - what is the actual problem?
Hi DR B
I use the First code for Drop down Menu and the Second code for process it
but no data Insert In The DataBase
Thanks alot
I see!
The first thing to do is to remove any error trapping: comment out the On Error Resume Next line and try again - do you get any errors?
Dr B
Hi What Is error trapping?
please say more
I want the complete Sourse Of This dropdown
[HTML]<select><option>1</option></select>[/HTML]
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dec |
last post by:
Ok to simplify things I'll just give an example.
This is pretty much what I want to do (minus the postcode):
http://www.perrys.co.uk/usedcar?ID=F5J9BNNBMVK00DF
I have relatively little...
|
by: kmnotes04 |
last post by:
Is it possible to link one drop-down box to another? For example, if a
name is chosen from a drop-down list, can another drop-down list then
automatically display the person's office as a result of...
|
by: callawayglfr |
last post by:
I am building a database in access where I have a drop down box that
relates to a text box, that part I have working but when someone
selects information from the first drop down I need it to limit...
|
by: Ed Dror |
last post by:
Hi there
ASP.NET 2.0 VB & SQL Express
Lest take Northwind Categories Products as example
I create a table that hold these two together
and I create a stored procedure like
select ProductID,...
|
by: penny111 |
last post by:
Hi there,
For my application, i need to have 3 drop down lists
1. drop down list of folder names
2. drop down list of documents in the folder selected
3. drop down list of instances of the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |