Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can anybody see what is wrong with this code ? 1

Status
Not open for further replies.

gojohnnygogogogo

Programmer
May 22, 2002
161
GB
hello,
I am passing some text to a page and I am getting a blank page.
(Apart from the view report button and the cy field)
I have done a response.write(SQL) and looks fine. ?:

<SCRIPT language=&quot;JAVASCRIPT&quot;>

function view_validate(form_ref) {

return true
}

</SCRIPT>

<%

dim cy, DfEE
cy = request.form(&quot;cy&quot;)
DfEE = request.form(&quot;DfEE&quot;)
%>


<%
Dim MyConncompany, SQLcompany, RScompany

Set MyConncompany=Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConncompany.Open &quot;schoolsasp&quot;,&quot;schoolsasp&quot;,&quot;schoolsasp&quot;

SQLcompany = &quot;SELECT EstablishmentID, DfEE, EstablishmentName From Establishments WHERE DfEE = '&quot;&DfEE&&quot;' ORDER BY EstablishmentName&quot;

Set RScompany = MyConncompany.Execute(SQLcompany)

%>

<FORM METHOD=&quot;POST&quot; name=&quot;myForm&quot; ACTION=&quot;./NCY3_2.asp&quot; onSubmit=&quot;return view_validate(this);&quot;>

'CAN SEE THIS BOX
<INPUT TYPE=&quot;TEXTBOX&quot; VALUE=&quot;<%=cy%>&quot; NAME=&quot;cy&quot;>

<% While Not RScompany.EOF %>

'THESE ARE BLANK, ?
<INPUT TYPE=&quot;TEXTBOX&quot; VALUE=&quot;<%=RScompany.Fields(&quot;EstablishmentName&quot;)%>&quot; NAME=&quot;Name&quot;>
<INPUT TYPE=&quot;TEXTBOX&quot; VALUE=&quot;<%=RScompany.Fields(&quot;DfEE&quot;)%>&quot; NAME=&quot;DfEE&quot;>

<%
RScompany.MoveNext
Wend
%>


<%
RScompany.Close
MyConncompany.Close
Set RScompany = Nothing
Set MyConncompany = Nothing
%>

thank you in advance
 
write these values to the page to test for actual value

Response.Write(RScompany(&quot;EstablishmentName&quot;) & &quot;<BR>&quot; & RScompany(&quot;DfEE&quot;))

also test the SQL statement by writing it to the page
Response.Write SQLcompany
see if it is actually stating what you want.

why are there three DSN's here with the same names
MyConncompany.Open &quot;schoolsasp&quot;,&quot;schoolsasp&quot;,&quot;schoolsasp&quot;
Was it something I said?
admin@onpntwebdesigns.com
 
sorry saw you tested the SQL Was it something I said?
admin@onpntwebdesigns.com
 
Hey snowboardr, thanks for the star. You're refering to the DSN thing right. that looked really odd. Was it something I said?
admin@onpntwebdesigns.com
 
Yes, I had to look at it twice.. haha www.vzio.com
ASP WEB DEVELOPMENT



 
thats not 3 dsn,s thats the username and password aswell as the odbc name,
is that wrong ?
 
I am trying response.write, but am getting this ewrror :
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.

?
I am putting the response.write here :

Set RScompany = MyConncompany.Execute(SQLcompany)
Response.Write(RScompany(&quot;EstablishmentName&quot;))
%>
 
Ah, you are receiving back an empty recordset. One thing you should alwys do before actually using a recordset (between executing and using it) is do an EOF check. If the recordset comes back without any data in it, than the row pointer in the recordset comes back as pointing to EOF, or past the bottom of the set. If you do some sort of check for EOF before trying to use any of the field you will limit your errors.
Code:
If RScompany.EOF Then
   Response.Write &quot;I am EOF!&quot;
Else
   Response.Write(RScompany(&quot;EstablishmentName&quot;))
End If
This way you will know while you are testing that a particular recordset came up blank. If this is the case, but you know the data is in your tables in such a way that it should have been selected, you know you have a problem with either your connection string or your sql query.
Print out your SQL query with the Request data in it. Then open your db and paste that sql string into it to see what kind of results you get. This usually helps me clear it up.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
cheers for the info.

I have worked out he problem now.
as I was passing multiple parameters my sql should have been like :

SELECT ID, NAME FROM TABLE WHERE ID IN (&quot;&ID&&quot;)

!! this works now.
thanks again,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top