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

<%
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"> </h3>
<p align="center"><font size="5" face="Arial, Helvetica,
sans-serif"><strong>DAPATKAN
KEMBALI KATALALUAN</strong></font></p>
<p align="center"> </p>
<form action=""name="kemkatalaluanForm" method="post" target="_parent">
<p>  </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> </td>
<td><input name="pwdId" type="hidden" id="pwdId"></td>
</tr>
</table>
<p align="left"><strong><font size="+2" face="Arial, Helvetica,
sans-serif">
                 
   
</font><font face="Arial, Helvetica, sans-serif">Katalaluan Anda :
</font><font size="+2" face="Arial, Helvetica,
sans-serif"> <%=rst("dKat1")%></font></strong></p>
                   
 
                <font
face="Arial, Helvetica, sans-serif"><strong>
Kembali ke Login, sila klik <a
href="http://localhost/remote_sistemKewangan/MainPage.asp">s ini</a>
</strong></font>
<p align="left"> </p>
</form>
<p align="center"> </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!!!


*** Sent via Developersdex http://www.developersdex.com ***
Chris Wu [ Di, 25 April 2006 09:43 ] [ ID #1288819 ]

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

Chris Wu wrote:
> <%
> 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 & "'"
>

At this point, enter the following:

response.write Strsql
response.end

then post the result from your browser here.

--
Mike Brind
Mike Brind [ Di, 25 April 2006 10:10 ] [ ID #1288821 ]

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

SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
dJa = '-'


This sql query is the result in my browser.

*** Sent via Developersdex http://www.developersdex.com ***
Chris Wu [ Di, 25 April 2006 13:02 ] [ ID #1288822 ]

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

SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
dJa = '-'

It is the result i get from my browser....

*** Sent via Developersdex http://www.developersdex.com ***
Chris Wu [ Di, 25 April 2006 13:02 ] [ ID #1288823 ]

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

Chris Wu wrote:
> 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
Mike Brind [ Di, 25 April 2006 13:50 ] [ ID #1288824 ]
Webserver » microsoft.public.inetserver.asp.db » Type mismatch: 'rst' and cant get value out from database

Vorheriges Thema: ASP to Check if a file exists on an FTP server
Nächstes Thema: I cant set validation for existing Username when submit a registration form