navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Combo box filled fine with hard coded not variables?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Combo box filled fine with hard coded not variables?
Page: [1]
 
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
Combo box filled fine with hard coded not variables? - 4/3/2001 19:44:00   
Hello, at my company we have novel log-in id's which is what the user also enters when going to my web site. So to identify entries in the database from users I am using a code that grabs the user id and puts it in one of the fields of the database.
I am trying to have the user retrieve records that pull up for only thier id and certain weekending dates in the database. If I hard code the user id in the code below the combo list box works just fine, but if I try and use the variable (previously submitted from another form) it does not work??? Anyone have any ideas? Here is the code:

<%
'Declare variables needed
Dim strSQL
Dim adCmdText
varuserID= request.form("user")
response.write varuserid
'Set required variables
adCmdText = 1

If Len(Request.Form("FormAction")) = 0 Then

'Create the recordset object
Set objRS = Server.CreateObject("ADODB.Recordset")

'Open the recordset
objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE 'varuserid'", "DSN=offstats"
%>


<form action=Ex.asp method=post name=frmDisplay>
<input type=hidden name=FormAction value=Step2>
<table>
<tr>
<td colspan=2>Select a we date to update</td>
</tr>
<tr>
<td>WE Date</td>
<td><select name=cbowedate>
<%
'Loop through the recordset adding wedate to the combo box
Do While Not objRS.EOF
%>
<option value="<%=objRS("wedate")%>">
<%=objRS("wedate")%></option>
<%
objRS.MoveNext

Loop

'Close and dereference database objects
objRS.Close
Set objRS = Nothing
%>
</select></td>
</tr>
<tr>
<td height=60><input type=submit name=btnSubmit value=Submit></td>
</tr>
</table>
</form>
--------------------------------
If I change this line:

objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE 'varuserid'", "DSN=offstats"

to THIS:

objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE 'rzm41v'", "DSN=offstats"

Replacing my ID with the varuserid it works fine, but this is hard coded, I need it for different users.

Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/3/2001 19:59:00   
All you are doing there, is continuing to hard code it.

objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE 'varuserid'", "DSN=offstats"

What you need to do, is enter it as a variable :

objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE '" & varuserid & "'", "DSN=offstats"

Im not sure why you would use LIKE? you should be searching for an exact match?



(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/3/2001 22:31:00   
Thanks Spooky, worked perfectly, but it always does when you help out

Can you explain the structure of the line of code to me so I can understand in the future? What does the & do?

Thanks!


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/3/2001 22:54:00   
Actually, just one more question Spooky, I forgot about something. After the user submits that information the form is coming up correctly but with the incorrect record, not the users record according to thier ID, just the first one in the database, so I need some guidance on the following line(s) of code:

strSQL = "Select * from Everyone where wedate = '" & _
CStr(Request.Form("cbowedate")) & "'"


The above is part of my update form script.

But it does not include the 'user' id field that we worked on previously, how would I include this to query where the varuserid matches the one entered on the previous form?

Hope im not being too confusing...Thanks again!


(in reply to AllenD)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/4/2001 13:33:00   
& is used to concatenate a string, or "join" it together.

objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE 'varuserid'"

The " signify the start and end of a string.

So if we need to insert a variable into a string, we need to break out of it at the point we are going to join a new variable.

objRS.Open "Select Distinct wedate from everyone WHERE edsnet LIKE '" <-- So we add a quote.

Now we want to join a variable to this string, so we use the &

To restart the string , we have to again add & and restart the " to let asp know we are continuing where we left off.

Im not quite sure where the ID comes in, but do you mean something like :

strSQL = "Select * from Everyone where wedate = '" & _
CStr(Request.Form("cbowedate")) & "' AND edsnet ='" & varuserid & "'"


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/4/2001 17:48:00   
Yes, that is what I am looking for (was that statement), but now i get this error when I use it...Not familiar with this error, any ideas?

Weekending date:
ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.

?


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/4/2001 18:14:00   
I tried playing around and hard coded it like this:

strSQL = "Select * from Everyone where wedate = '" & _
CStr(Request.Form("cbowedate")) & "' AND edsnet LIKE 'VMCWEB\rzm41v' "'",

-------------------------
and that seems to work, but when trying to use varuserid in its place I get the error I talked about above???


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/5/2001 16:15:00   
Spooky, can u help me with just the one line of code listed above so I can finish my project, then I am going to ASP Class!!!

Thanks,
Allen

(in reply to AllenD)
Vince from Spain

 

Posts: 658
From: Madrid Spain
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/6/2001 20:12:00   
Hi there,
if your query works when the value is hard coded, and doesn't when using a variable, then probably the value of the variable is not what you thought it was. Try printing out the SQL statement after substituting the variable (Response.Write strSQL) and make sure it is exactly what you have for the version that works.

Vince

------------------
Internet Business Solutions S.L.(Spain)


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/8/2001 20:55:00   
Any ideas on this Spooky?

(in reply to AllenD)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/9/2001 20:19:00   
What does Vinces suggestion look like?

(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/9/2001 16:54:00   
Ok, when using response.write to show the statement I get this:

Select * from Everyone where wedate = '02/03/01' AND edsnet =''
Weekending date:
ADODB.Fields error '800a0cc1'

ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.

/reports/stats/Ex.asp, line 81

-----------
It appears that the varuserid is not writing the ID...Above the statement I do a response.write varuserid and it is showing the correct ID that I need, it just is not working in the statement for some reason.


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/9/2001 17:01:00   
Sorry, I keep refering to ID because we call the user names EDSNET ID's...im not refering to the key in the access file...im refering to the field called edsnet.

Thanks...


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: Combo box filled fine with hard coded not variables? - 4/9/2001 17:59:00   
I fixed it. I just made a hidden text box contaning the edsnetid called varuserid and did this:

strSQL = "Select * from Everyone where wedate = '" & _
CStr(Request.Form("cbowedate")) & "' AND edsnet = '" & CStr(Request.Form("varuserid")) & "'"


Works great! Thanks everyone




(in reply to AllenD)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Combo box filled fine with hard coded not variables?
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts