Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / April 2006



Tip: Looking for answers? Try searching our database.

Type mismatch: 'rst' and cant get value out from database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Wu - 25 Apr 2006 08:43 GMT
<%
   strODBC = "Driver={MySQL};" & _
             "Server=localhost;" & _
             "Database=sistemkewangan;" & _
             "Uid=root;" & _
             "Pwd=;"
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
pwdNama = request.Form("pwdNama")
pwdsoalan = request.Form("pwdsoalan")
pwdJawapan = request.Form("pwdJawapan")

Dim Objrs
   set Objrs = Server.CreateObject("ADODB.Connection")
   Objrs.Open strODBC
   
Dim Strsql
    Strsql = "SELECT dKat1 FROM pendaftaran WHERE dNId = '" & pwdNama & "'"
    Strsql = Strsql + " AND " & "dSoa = " & "'" & pwdsoalan & "'"
   Strsql = Strsql + " AND " & "dJa = " & "'" & pwdJawapan & "'"

    set rst = Objrs.Execute(Strsql)
   
    if rst.eof then
     Set rst = Nothing
     Set Objrs = Nothing
     response.write "<script language=JavaScript>"
     response.write "alert('Tiada Nama Id anda!!');"
     response.write "location.replace('MainPage.asp');"
     response.write "</script>"
    end if
%>

<html>
<head>
<title>Kembali Katalaluan</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">

enableJS();
is_form_submited=1;
return true;
}   

</script>
</head>

<body bgcolor="#FFFFFF">
<h3 align="center">&nbsp;</h3>
<p align="center"><font size="5" face="Arial, Helvetica,
sans-serif"><strong>DAPATKAN
 KEMBALI KATALALUAN</strong></font></p>
<p align="center">&nbsp;</p>
<form  action=""name="kemkatalaluanForm" method="post" target="_parent">
 <p>&nbsp; </p>
 <table width="56%" border="0" align="center">
   <tr>
     <td width="19%"><strong><font color="#FF3300" size="2"
face="Arial, Helvetica, sans-serif">NAMA
       ID </font></strong></td>
     <td width="81%"><input name="pwdNama" type="text" id="pwdNama"
size="30" maxlength="50"></td>
   </tr>
   <tr>
     <td><strong><font color="#FF3300" size="2" face="Arial, Helvetica,
sans-serif">SOALAN</font></strong></td>
     <td><select name="pwdsoalan" id="pwdsoalan">
         <option value="1">Apakah nama binatang kesayangan
anda?</option>
         <option value="2">Apakah nama sekolah pertama anda
belajari?</option>
         <option value="3">Siapakah pahlawan anda gemari semasa
kecil?</option>
         <option value="4">Apakah kegemaran anda masa lalu?</option>
         <option value="5">Apakah pasukan sukan yang anda
gemari?</option>
         <option value="6">Apakah kereta/basikal pertama anda?</option>
         <option value="7">Di mana anda jumpa isteri anda pada pertama
kali?</option>
       </select></td>
   </tr>
   <tr>
     <td><strong><font color="#FF3300" size="2" face="Arial, Helvetica,
sans-serif">JAWAPAN</font></strong></td>
     <td><input name="pwdJawapan" type="text" id="pwdJawapan" size="53"
maxlength="52"
onChange="javascript:this.value=this.value.toUpperCase();"></td>
   </tr>
   <tr>
     <td>&nbsp;</td>
     <td><input name="pwdId" type="hidden" id="pwdId"></td>
   </tr>
 </table>
 <p align="left"><strong><font size="+2" face="Arial, Helvetica,
sans-serif">
   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;
   </font><font face="Arial, Helvetica, sans-serif">Katalaluan Anda :
</font><font size="+2" face="Arial, Helvetica,
sans-serif">&nbsp;<%=rst("dKat1")%></font></strong></p>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <font
face="Arial, Helvetica, sans-serif"><strong>
 Kembali ke Login, sila klik <a
href="http://localhost/remote_sistemKewangan/MainPage.asp">sini</a>
 </strong></font>
 <p align="left">&nbsp;</p>
</form>
<p align="center">&nbsp;</p>
<p align="center"><strong><font size="+2" face="Arial, Helvetica,
sans-serif">
 </font></strong></p>
</body>
</html>
<%
rst.Close()
Set rst = Nothing
%>

pls solve my problem....i cant get back password from database
MySQL.Thank you!!!
Mike Brind - 25 Apr 2006 09:10 GMT
> <%
>     strODBC = "Driver={MySQL};" & _
[quoted text clipped - 18 lines]
>     Strsql = Strsql + " AND " & "dSoa = " & "'" & pwdsoalan & "'"
>     Strsql = Strsql + " AND " & "dJa = " & "'" & pwdJawapan & "'"

At this point, enter the following:

response.write Strsql
response.end

then post the result from your browser here.

--
Mike Brind
Chris Wu - 25 Apr 2006 12:02 GMT
SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
dJa = '-'

This sql query is the result in my browser.
Mike Brind - 25 Apr 2006 12:50 GMT
> SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
> dJa = '-'
>
> This sql query is the result in my browser.

And does it give you any records if you run it against your database?
I suspect that it does not - which means that the code for rst.eof
runs, and within that, the recordset is set to nothing.  Then you refer
to it again further down in your code, but by this time the object has
been destroyed.

You probably think that the javascript redirect would ensure that the
code lower down doesn't get run if rst.eof, but that's not how it
works.  The whole page is parsed by the    ASP engine from top to
bottom PRIOR to the resulting html being sent to the client.  Client
side Javascript will not run until it has reached the client
(obviously).

I would change the If rst.eof code to this:

if rst.eof then
   response.write "<script language=JavaScript>"
   response.write "alert('Tiada Nama Id anda!!');"
   response.write "location.replace('MainPage.asp');"
   response.write "</script>"
Else
   dKat1 = rst("dKat1")
end if
Set rst = Nothing
Set Objrs = Nothing

Then <%= dKat1 %> should go later in your script, and you will need to
delete the rst.Close()
Set rst = Nothing
at the bottom.

--
Mike Brind
Chris Wu - 25 Apr 2006 12:02 GMT
SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
dJa = '-'

It is the result i get from my browser....
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.