|
-
Aug 16th, 2004, 07:43 PM
#1
Thread Starter
Giants World Champs!!!!
Loading Combobox from SQL
I trying to load a combobox and I am having a few problems, here is my code:
VB Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim MM_DB_STRING
MM_DB_STRING = "Provider=SQLOLEDB;Data Source=(Local);" _
& "Initial Catalog=IADATA;User Id=UserName;Password=Password;"
Dim customerRS
Dim customerRS_numRows
Dim Customer
Set customerRS = Server.CreateObject("ADODB.Recordset")
customerRS.ActiveConnection = MM_DB_STRING
customerRS.Source = "select USERLNAM, P_WORD from CURRENT_Users"
customerRS.CursorType = 0
customerRS.CursorLocation = 2
customerRS.LockType = 1
customerRS.Open()
customerRS_numRows = 0
%>
<%
While (NOT customerRS.EOF)
%>
<%
Customer =(customerRS.Fields.Item("USERLNAM").Value)%><%=(customerRS.Fields.Item("USERLNAM").Value)%>
<%
customerRS.MoveNext()
Wend
If (customerRS.CursorType > 0) Then
customerRS.MoveFirst
Else
customerRS.Requery
End If
%>
<%
customerRS.Close()
Set customerRS = Nothing
%>
And the actionscript
my_lv = new LoadVars();
my_lv.onLoad = handleLoad;
my_lv.load("combobox.asp");
function handleLoad(success) {
if(success) {
for(var i in this) _root.customer.addItem(i,this[i]);
} else {
trace("Problems loading combo data!");
}
}
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."
-
Aug 16th, 2004, 08:01 PM
#2
Thread Starter
Giants World Champs!!!!
DSN-Less Connection
I adjusted my code as follows:
VB Code:
<html>
<head>
<title>Page 1</title>
</head>
<body>
<%
set conn = server.createobject("ADODB.Connection")
conn.open("dsn=IADATA;user id=UserName;password=Password")
sql = "select USRNUM, USERLNAM, USERFNAM, TITLE, P_Word FROM Current_Users"
set rs = conn.execute(sql)
%>
<form name="form1" method="POST" action="page2.asp">
<select name="select1">
<%
do while not rs.eof
name = rs("USERLNAM") & ", " & rs("USERFNAM") & ", " & rs("Title")
response.write("<option value=" & rs("Usrnum") & ">" & Name)
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</select>
<input type="submit" name="submit" value="OK">
</form>
</body>
</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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|