Results 1 to 2 of 2

Thread: Loading Combobox from SQL

  1. #1

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Loading Combobox from SQL

    I trying to load a combobox and I am having a few problems, here is my code:

    VB Code:
    1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    2. <%
    3.  
    4. Dim MM_DB_STRING
    5.  
    6. MM_DB_STRING = "Provider=SQLOLEDB;Data Source=(Local);" _
    7.         & "Initial Catalog=IADATA;User Id=UserName;Password=Password;"
    8.  
    9. Dim customerRS
    10. Dim customerRS_numRows
    11. Dim Customer
    12.  
    13. Set customerRS = Server.CreateObject("ADODB.Recordset")
    14. customerRS.ActiveConnection = MM_DB_STRING
    15. customerRS.Source = "select USERLNAM, P_WORD from CURRENT_Users"
    16. customerRS.CursorType = 0
    17. customerRS.CursorLocation = 2
    18. customerRS.LockType = 1
    19. customerRS.Open()
    20.  
    21. customerRS_numRows = 0
    22. %>
    23. <%
    24. While (NOT customerRS.EOF)
    25. %>
    26.  
    27. <%
    28. Customer =(customerRS.Fields.Item("USERLNAM").Value)%><%=(customerRS.Fields.Item("USERLNAM").Value)%>
    29. <%
    30. customerRS.MoveNext()
    31. Wend
    32. If (customerRS.CursorType > 0) Then
    33. customerRS.MoveFirst
    34. Else
    35. customerRS.Requery
    36. End If
    37. %>
    38.  
    39.  
    40. <%
    41. customerRS.Close()
    42. Set customerRS = Nothing
    43. %>
    44.  
    45. And the actionscript
    46.  
    47.  
    48. my_lv = new LoadVars();
    49. my_lv.onLoad = handleLoad;
    50. my_lv.load("combobox.asp");
    51. function handleLoad(success) {
    52. if(success) {
    53. for(var i in this) _root.customer.addItem(i,this[i]);
    54. } else {
    55. trace("Problems loading combo data!");
    56. }
    57. }

    Any suggestions?

    Thanks
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  2. #2

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    DSN-Less Connection

    I adjusted my code as follows:

    VB Code:
    1. <html>
    2. <head>
    3. <title>Page 1</title>
    4. </head>
    5. <body>
    6. <%
    7. set conn = server.createobject("ADODB.Connection")
    8. conn.open("dsn=IADATA;user id=UserName;password=Password")
    9. sql = "select USRNUM, USERLNAM, USERFNAM, TITLE, P_Word FROM Current_Users"
    10. set rs = conn.execute(sql)
    11. %>
    12. <form name="form1" method="POST" action="page2.asp">
    13. <select name="select1">
    14. <%
    15. do while not rs.eof
    16. name = rs("USERLNAM") & ", " & rs("USERFNAM") & ", " & rs("Title")
    17.  response.write("<option value=" & rs("Usrnum") & ">" & Name)
    18.  rs.movenext
    19. loop
    20. rs.close
    21. set rs=nothing
    22. conn.close
    23. set conn=nothing
    24. %>
    25. </select>
    26. <input type="submit" name="submit" value="OK">
    27. </form>
    28. </body>
    29. </html>

    But I want to make this code DSN-Less any suggestions??


    Thanks
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width