473,387 Members | 1,798 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,387 software developers and data experts.

Add Drop Down TO ACCESS

12
Hi
I want to add a dropdown Menu to my ACCESS database With ASP
Please Help Me
Jul 23 '08 #1
6 1915
DrBunchman
979 Expert 512MB
Hi mbm2000,

To populate a drop down list from a database in ASP you can do the following:
Expand|Select|Wrap|Line Numbers
  1.  <% 
  2. 'Initialise the recordset and connection objects and open the connection
  3. Dim oRS, oConn, sSQL
  4. Set oConn = Server.CreateObject("ADODB.Connection")
  5. oConn.Open CONNECTION_STRING
  6. Set oRS = Server.CreateObject ("ADODB.Recordset")
  7.  
  8. 'Define the SQL used to query the database
  9. sSQL = "SELECT ValueColumn, NameColumn FROM Table1 WHERE id = 1"
  10.  
  11. 'Open the recordset
  12. oRS.Open sSQL, oConn, 3
  13.  
  14. Response.Write "<select name='dropdown1'>"
  15.  
  16. 'Loop through the recordset, writing an option for each row
  17. Do Until oRS.EOF
  18.      Response.Write "<option value='" & oRS("ValueColumn") & ">"
  19.      Response.Write oRS("NameColumn")
  20.      Response.Write "</option>"
  21.      oRS.MoveNext
  22. Loop
  23.  
  24. Response.Write "</select>"
  25.  
  26. 'Destroy the objects
  27. Set oRS = Nothing
  28. oConn.Close
  29. Set oConn = Nothing
  30. %>
  31.  
Does this help at all? Let me know.

Dr B
Jul 23 '08 #2
mbm2000
12
HI DR B
I want put this data to my access db
I use This code for Drop Down Menu
Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="star"value="<%= star %>">
  2.     <option selected>0</option>
  3.     <option>1</option>
  4.     <option>2</option>
  5.     <option>3</option>
  6.     <option>4</option>
  7.     <option>5</option>
  8.     <option>6</option>
  9.     <option>7</option>
  10.   </select>
  11.  
and This Code For proccess
Expand|Select|Wrap|Line Numbers
  1. <!--#include file="header.asp"-->
  2. <% 
  3. On Error Resume Next
  4. If Request.Cookies("user_logged_ID" & strSUnique) = Empty then Response.Redirect "register.asp"
  5. If Request.Form("catID") = Empty Or Request.Form("subcatID") = Empty then Response.Redirect "post_new1.asp"
  6. If isnotfree And Not Request.Cookies("allow_post" & strSUnique) = "True" then Response.Redirect "filter.asp?url=post_new1.asp&act=startOver"
  7.  
  8. If isnotfree then
  9.     set rs = objConn.Execute("SELECT credits FROM " & tablUPfx & "User WHERE userID = " & CLng(session("user_logged_ID" & strSUnique)) & ";")
  10.     If not rs.EOF then Session("user_logged_credit" & strSUnique) = FormatNumber(CCur(rs("credits")), 2)
  11.     rs.close
  12.     If CCur(Request.Cookies("final_price" & strSUnique)) > CCur(Session("user_logged_credit" & strSUnique)) Then 
  13.         Response.Write strText_NotEnoughCredits
  14.         Response.End
  15.     End If
  16. End If
  17.  
  18.  
  19. Dim msg, star
  20. setLocale server_locale
  21. sdd = dd(objConn)
  22.  
  23. userID = CLng(Request.Cookies("user_logged_ID" & strSUnique))
  24. postExpire = DateAdd("d", CLng(Request.Form("S1")), Now)
  25.  
  26.  
  27. star = Request.form("star")
  28.  
  29. IP = Request.ServerVariables("REMOTE_ADDR")
  30. adID = subcatID & RandomNumber & userID
  31. adID = CStr(adID)
  32. If moderate then active = 0: Else: active = 1
  33. If len(subject) > 0 and Len(descr) > 0 Then
  34.  
  35. If not Request.Form("imgFile") = Empty then
  36.     img = sq(Request.Form("imgFile"))
  37.     imgArray = Split(img, sf)
  38.     For d = 0 to UBound(imgArray) - 1
  39.         imgName = Split(imgArray(d), "|")(0)
  40.         set rs = objConn.Execute("SELECT " & tablPfx & "Temp.tempimg FROM " & tablPfx & "Temp WHERE tempimg = '" & imgName & "';")
  41.         If Not rs.EOF then objConn.Execute("DELETE FROM " & tablPfx & "Temp WHERE tempimg = '" & imgName & "';")
  42.         rs.close
  43.     Next
  44. End If
  45.  
  46. If isnotfree then 
  47.     hotlist = Request.Cookies("hotlist" & strSUnique)
  48.     'If Len(img) > 0 then
  49.         userimglimit = Request.Cookies("image_limit" & strSUnique)
  50.     'Else: userimglimit = 0        
  51.     'End If
  52. Else
  53.     userimglimit = imagelimit
  54.     hotlist = 0
  55. End If
  56.  
  57. For uo = 0 to 7
  58.     nextUserFormText = Request.Form("uO" & uo)
  59.     If Len(nextUserFormText) = 0 then nextUserFormText = Request.Form("uCOF" & uo)
  60.     strUserValues = strUserValues & ", '" & sq(HTMLEncode(nextUserFormText)) & "'"    
  61.     strUserFields = strUserFields & ", " & "uopt" & uo + 1
  62. Next
  63.  
  64. For o = 1 to 20
  65.     nextFormText = Request.Form("O" & o)
  66.     If Len(nextFormText) = 0 then nextFormText = Request.Form("COF" & o)
  67.     nextFormText = Replace(Replace(nextFormText, "<", "&lt;"), ">", "&gt;")
  68.     nextFormText = sq(HTMLEncode(nextFormText))
  69.     strCatValues = strCatValues & ", '" & nextFormText & "'"
  70.     strCatFields = strCatFields & ", " & "opt" & o
  71. Next
  72.  
  73. 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"
  74. strSQL = strSQL & strUserFields & strCatFields & ", userimagelimit) VALUES ('" & adID & "', " & catID & ", " & subcatID & ", " & cat3rdID & ", " & userID & ", " & sdd & PostPosted & sdd & ", " & sdd & postExpire & sdd & ", '" & nick & "', "
  75. strSQL = strSQL & "'" & city & "', '" & subject & "', '" & phone & "', '" & URL & "', '" & img & "', '" & onlineImg & "', '" & descr & "', " & active & ", '" & IP & "', "
  76. strSQL = strSQL & 0 & ", " & hotlist & ", '" & star & "', '" & price & "'" & strUserValues & strCatValues & ", " & userimglimit & ");"
  77.  
  78. objConn.Execute(strSQL)
  79.  
  80. Call updateUserPostData(userID, adID, price, "postnew")
  81.  
  82. If moderate then
  83.     Call getTemplate("New_Ad_Pending", email, Empty, nick, Empty, adID)
  84. Else
  85.     Call UpdateList(True, catID, subcatID, cat3rdID)
  86.     Call getTemplate("New_Ad_Approved", email, Empty, nick, Empty, adID)
  87.     Application("cl_marquee" & strUnique) = Empty
  88.     Call matchAlerts(adID, catID, subcatID, cat3rdID, subject, descr)
  89. End If
  90.  
  91. If IsCache then Call cacheAds(adID)
  92.  
  93. Call sendEmail(email, notify_email, uSubject, uBody)
  94. Call getTemplate("Admin_Notify", email, Empty, nick, Empty, adID)
  95. Call sendEmail(admin_email, notify_email, uSubject, uBody)
  96. If isEvents then Call logEvent("New Ad", adID, subject, Empty, Empty, Empty)
  97.  
  98. Response.Cookies("user_logged_ID" & strSUnique) = Empty
  99. Session("image_limit" & strSUnique) = Empty
  100. Session("duration_limit" & strSUnique) = Empty
  101. Session("hotlist" & strSUnique) = Empty
  102. Session("allow_post" & strSUnique) = Empty
  103. Session("final_price" & strSUnique) = Empty
  104. session("Select_Category" & strSUnique) = Empty
  105. session("Select_SubCategory" & strSUnique) = Empty
  106. session("Select_CategoryID" & strSUnique) = Empty
  107. session("Select_SubCategoryID" & strSUnique) = Empty
  108. session("Select_3rdCategory" & strSUnique) = Empty
  109. session("Select_3rdCategoryID" & strSUnique) = Empty
  110. Session("Attach_Image" & strSUnique) = Empty
  111. Set session("Attach_Image" & strSUnique) = Nothing
  112. Set session("Temp_UserArray" & strSUnique) = Nothing
  113. Session("Count_Image" & strSUnique) = Empty
  114.  
  115.  
  116. Response.Write "<br><div align='center'>" & strText_Posted & "&nbsp;<b>" & email & "</b></div><br>"
  117. If moderate then Response.Write "<div align='center'>" & strText_Posted1 & "</div><br>"
  118. End If
  119. %><!--#include file="tneval_footer.asp"--><!--#include file="footer.asp"-->
  120.  
  121.  
Thanks alot DR B
Jul 23 '08 #3
DrBunchman
979 Expert 512MB
Sorry, I'm a bit confused - what is the actual problem?
Jul 23 '08 #4
mbm2000
12
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
Jul 23 '08 #5
DrBunchman
979 Expert 512MB
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
Jul 23 '08 #6
mbm2000
12
Hi What Is error trapping?
please say more
I want the complete Sourse Of This dropdown
[HTML]<select><option>1</option></select>[/HTML]
Jul 23 '08 #7

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

Similar topics

1
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...
2
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...
7
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...
8
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,...
3
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...
0
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,...
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: 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$) { } ...
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...
0
BarryA
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...
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
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...

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.