Avatar billede knutbl Nybegynder
08. september 2002 - 22:48 Der er 13 kommentarer og
1 løsning

error '800a000d' Type mismatch: 'CInt' ??????

Har et webcard-script, og får denne error-koden når man skal se det sendte kortet:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'CInt'
/web/interact/webcard/view.asp, line 73

Er ingen racer i asp selv (grunnkoden er nedlastet fra hotscript.com, eller noe slikt), og jeg lurer på hva som er feil i koden min. Her er HELE koden i view.asp.

Linje 73 er
SQLStmt = "SELECT * FROM postal WHERE ID_POSTAL = " & _

___________________KODE HER_______________________

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
Dim fromn
Dim ident
Dim psw

' erring tells us if the card already
' exists.  By default, we assum it does.
Dim erring 

' I normaly use 0 and 1 for boolean, 
' cause it is quicker
erring = 0 


' Receiving the information   
' from the link that led to this file;
' this one tell us
' what kind of access we're doing
fromn = Request.QueryString("fromn")
 
' here we take the ID from the post card, 
' for us to know wich card we want to see.
' All this information will be compared with 
' the one in the database.
ident = Request.QueryString("ident") 


' This is the password
' We do not want a person that knows there exists a 
' postcard with ID 13 tries to see one with ID 12.
' We will generate a random number for the password
psw = Request.QueryString("psw") 

if fromn = "seeit" then 
    ' If we just want to see the preview
    ' I have created sessions to keep the information,
    ' so that I can view the data at any step
    session("postal") = Request.form("R1")
    session("namefrom") = Request.form("namefrom")
    session("emailfrom") = Request.form("emailfrom")

    session("nameto") = Request.form("nameto")
    session("emailto") = Request.form("emailto")
    session("message") = Request.form("message")
else 
    'Someone is wanting to see an already sent card

    'Open the DB connection
    Set Conn = Server.CreateObject("ADODB.Connection")

    ' DSNless connection to Access Database
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("postal.mdb")
conn.Open DSNtemp
' DSNless connection to Access Database
   


    'Create a recordset
    Set rs = Server.CreateObject("ADODB.Recordset") 


    ' This is asimple SQL statement that see if the ID and 
    ' password are connected in the DB
    SQLStmt = "SELECT * FROM postal WHERE ID_POSTAL = " & _
    CInt(ident) & " AND passw = " & CInt(psw)

    ' Execute the SQL statementz
    rs.Open SQLstmt, Conn, 1, 2


    if rs.EOF then
      'Post card doesn't exist or invalid password!
        erring = 1 
    else 
      'Postcard does exist.  Populate the session
      'variables with the database info.
        session("postal") = rs("postal")
        session("namefrom") = rs("namefrom")
        session("emailfrom") = rs("emailfrom")
        session("nameto") = rs("nameto")
        session("emailto") = rs("emailto")
        session("message") = rs("message")
'if fromn have "seeit we will show =
    end if
end if
%>

<html>
<body
    marginheight="0"
    marginwidth="0"
    topmargin="0"
    leftmargin="0"
    background="images/something.gif"
    bgcolor="#002400"
    text="#FCC403"
>

<%
' At this time we will see if there has been an error
' We also want to make sure the form data is valid.

if erring <> 1 and (fromn="seeit" or fromn="out") and session("postal") <> "" then

    ' if everything is correct we show the information
%>
<div align="left">
<table border="0" width="580" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%" valign="top" align="left"><br>
      <br>
      <img src="images/<%=session("postal")%>.jpg" hspace="5"
          border="2" WIDTH="354" HEIGHT="231">
    </td>
    <td width="50%">
      <table border="0" cellspacing="3" width="100%" cellpadding="3"
              bordercolor="#000000" height="202">
        <tr>
          <td width="100%" height="109">
              <p align="left">
              <font face="Arial"><br>
                <small>From:</small>
                <strong><%=session("namefrom")%></strong>
                <br>
                <small>Email:</small><small><strong>
                <%=session("emailfrom")%></strong></small>
                <br>
                <small>To:</small><strong><small>
                <%=session("nameto")%></small></strong>
                <br>
                <small>Email:</small><small><strong>
                <%=session("emailto")%></strong></small>
              </font>
            </td>
          </tr>

          <tr>
            <td width="100%">
              <font face="Arial">
                <small>Message:</small><br>
                <font size="2"><strong>
                <%=session("message")%></strong>
                </font>
              </font>
            </td>
          </tr>

          <tr>
            <td width="100%" align="center" valign="middle" height="29">
            <%
              'if fromn == "seeit" we will show the
            'buttons "to send" and "to retry"
              if fromn="seeit" then 
            %>
              <p align="left"><br>
                <a href="java script:history.back()"> <img src="images/rebuildbotton.gif" width="60"
                    height="53" border="0"> </a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="enviado.asp"> <img src="images/sendbotton.gif" width="41"
                      height="53" border="0"></a> </td>
          </tr>
          </table>
        </td>
      </tr>
  </table>
</div>

          <%
            ' Someone is viewing a card already made
        ' Show the reply button 
            else 
          %>
              <br><br><br>
<a href="makin.htm" target="_self" > <img border="0" height="72" src="images/replybotton.gif"
                      width="176"></a>
<%
            end if

' This else will only be reached if there is no card
' (i.e. the password was incorrect)  We need to show
' an error message.
else
%> 

<br><br>
<center>
  <img src="images/error.gif" width="322" height="53"
    border="0">
</center>
<br>

<%
end if   


' This is where i remove all the postcards 
' in the DB with more than 30 days old.

' I do not want to make a huge DB, so I clean 
' it just to have the messages of the last 30 days.

' You can now ask.. "-So, why did you put this code here?"
' My response is:
' "- Because this is the place where you fill the DB,
' so if you are going to put another record
' at the DB, lets clean some old stuff."

' That being said, let's clean the db!  :)

' Here we will get the system date (yes, the server date)
d = now() 

' We will decrease 30 days at the date we have
d = DateAdd("d",-30,d)
Set Conn = Server.CreateObject("ADODB.Connection")
' DSNless connection to Access Database
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("postal.mdb")
conn.Open DSNtemp
' DSNless connection to Access Database

Set rs = Server.CreateObject("ADODB.Recordset") 

' Run a SQL query that will remove all out of date records
SQLStmt = "DELETE FROM postal WHERE data < #" & d & "#" '

'Run the query
rs.Open SQLstmt,Conn,1,2 
%>

</body>   
</html>
Avatar billede eagleeye Praktikant
08. september 2002 - 23:03 #1
SQL'en er på to linier...:

    SQLStmt = "SELECT * FROM postal WHERE ID_POSTAL = " & _
    CInt(ident) & " AND passw = " & CInt(psw)


Så linket skulle lige nioget i stil med: view.asp?ident=xxx
hror xxx er det postkort som skal vises.


ident kommer fra Request.QueryString  så linket til siden skal have en querystring...:
Avatar billede knutbl Nybegynder
08. september 2002 - 23:08 #2
Hmmm, som sagt er jeg ingen racer: Kan du forklare dette nærmere? Gjerne med kode?
KnB
Avatar billede eagleeye Praktikant
08. september 2002 - 23:11 #3
Ja den fejler i linien / koden :    CInt(ident)

CInt er en function som konvere en streng til til et heltal. Hvis den streng man angiver her ident så kommer den fejl du får.
Avatar billede knutbl Nybegynder
08. september 2002 - 23:14 #4
Og hvordan løser jeg problemet?
Avatar billede eagleeye Praktikant
08. september 2002 - 23:17 #5
Jeg kender ikke det script fra hotscripts men den hendter ident i denne linie:

ident = Request.QueryString("ident") 

og QueryString betyder en streng som er efter filnanvet i linket.. view.asp?odent=3232

Så nårdan linker du til den side??
Avatar billede eagleeye Praktikant
08. september 2002 - 23:25 #6
så vidt jeg kan se bruges den fil til at vise det post kort man har fået og til at vise et preview til den som sender det.. Hvis filen skal vise et billede forvendter den linket set sådan ud:


view.asp?ident=10&psw=234

Det betyder den viser Postkort med ID = 10 og dertil hørne password 234 som er automatisk lavet ved afsendelse i følge beskrivelsen.
Avatar billede eagleeye Praktikant
08. september 2002 - 23:34 #7
Jeg håber det har givet dig lidt hjælp til at komme vidre... men jeg er nød til at gå i seng nu.
Avatar billede knutbl Nybegynder
08. september 2002 - 23:34 #8
Linken som blir sendt til mottakeren ser slik ut:
http://www.delawaremusic.net/web/interact/webcards/view.asp?fromn=out&ident=&psw=3027

Det er 2 andre filer (utenom databasen) som fulgte med i zip'en fra hotscripts (tror det var der den ble hentet). Her er de i to forskjellige kommentarer...

___________________KODE makin.htm________________________________

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<form name="postalsent" method="post" action="view.asp?fromn=seeit" target="_self">

.....
    <td width="24" valign="bottom">
      <font face="Arial">
        <input type="radio" value="postal1" name ="R1">
      </font>
    </td>

    <td width="140">
      <font face="Arial">
      <IMG border=2 height=86 src="images/postal1.gif" width=134>
      </font>
    </td>

    <td width="12" valign="bottom">
      <font face=3D"Arial">               
          <input type="radio" value="postal2" name ="R1">
      </font>
    </td>

    <td width="151">
      <font face="Arial">
          <IMG border=2 height=87 src="images/postal2.gif" width=134>
      </font>
    </td>
  </tr>
<tr>
  <td width="24" valign="bottom"> <font face="Arial">
    <input type="radio" value="postal3" name="R1">
    </font> </td>
  <td width="140"> <font face="Arial"> <IMG border=2 height=88 src="images/postal3.gif" width=135>
    </font> </td>
  <td width="12" valign="bottom"> <font face="Arial">
  <input type="radio" value="postal4" name="R1">
  ...... 
<tr> <font color="#666666">TO (name)</font>
<tr>
  <INPUT name="nameto" size=18 style="LEFT: 1px; TOP: 2px">
<br>
<tr> TO (email)
<tr>
  <input name="emailto" size="18">
<br>
<tr> FROM (name)
<tr>
  <input name="namefrom" size="18">
<br>
<tr> FROM (email)
<tr>
  <input name="emailfrom" size="18">
<br>
<tr>
  <TEXTAREA cols=18 name=message rows=2></TEXTAREA>
<br>
<tr>
  <td width="32%"><input type="image" name="bseeit" src="images/seesentbotton.gif"
      border=0 height=51 width=110> <a href="makin.htm"> <img border=0 height=53 src="images/resetbotton.gif" width=41>
    </a> </td>
  ......
</body>
</html>
Avatar billede knutbl Nybegynder
08. september 2002 - 23:37 #9
__________________KODE ENVIADO.ASP________________________________
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Delaware e-cards (delawaremusic.net)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%

' This is the variable that I use to the ID 
' of the post card
Dim identifier

' goby is anotther  boolean to 
' see if there is an error in the data
Dim goby

goby = 1    'lets start it with True

%>

<html>
<body
    marginheight="0"
    marginwidth="0"
    topmargin="0"
    leftmargin="0"
    bgcolor="#006699"
    text="#cccccc"
>

<font face=3D"Arial">
<small><strong>

<%
' Let's validate the name; the length of the
' name must be at least 2 characters long
if len(session("nameto")) < 2 then 
    ' So if there is any problem there will be an error 
    goby = 0 
end if


if len(session("namefrom")) < 2 then
    goby = 0
end if


' Validate the e-mail, I have written
' an arthicle about this, take a look at it
If Len(session("emailfrom")) <= 5 Then 
    goby = 0
Else
    If InStr(1, session("emailfrom"), "@", 1) < 2 Then
        goby = 0
    Else
        If InStr(1,session("emailfrom"), ".", 1) < 4 Then
            goby = 0
        End If
    End If
End If

If Len(session("emailto")) <= 5 Then
    goby = 0 
Else
    If InStr(1, session("emailto"), "@", 1) < 2 Then
        goby = 0
    Else
        If InStr(1,session("emailto"), ".", 1) < 4 Then
            goby = 0
        End If
    End If
End If


' Make sure the message is less than 500 characters.
If len(session("message")) >= 500 Then 
    goby = 0
End If


' If there are errors, then let the user know
' And make him/her correct the data
if goby = 0 then %>

  <br><br><br><br><br>
  <center>
      <img src="images/error.gif" width="322" 
          height="53" border="0">
  </center>
  <br>
<%
end if


' There are no errors.  Put the data in the DB
' and send the link to the receiver via email.
If goby = 1 then 
set conn=server.createobject("adodb.connection")
' DSNless connection to Access Database
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("postal.mdb")
conn.Open DSNtemp
' DSNless connection to Access Database
   
    Set rs = Server.CreateObject("ADODB.Recordset")

    'We need to insert a record into the database
    SQLStmt = "INSERT INTO postal (" & _
              "passw, postal, nameto, namefrom, " & _
              "emailfrom, emailto, message, data) " & _
          "VALUES ("

    ' We need a random number for our password, so
    ' use randomize/rnd to make a random number.
    randomize()
    passw = Int((9999-1)*Rnd + 1)

    SQLStmt = SQLStmt & passw & ",'" & session("postal") & _
              "','" & session("nameto") & "','" & _
              session("namefrom") & "','" & _
              session("emailfrom") & "','" & _
              session("emailto") & "','" & _
              session("message") & "','" & session("data") & "')"

    ' Write information to database
    rs.Open SQLStmt, Conn


   

    ' First, Create the Mail object
    Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

    ' Put the mail server you are using
Mailer.RemoteHost = "smtp.activeisp.com"

    ' Send the information of the
    ' person that is sending the e-mail
  Mailer.FromAddress = session("emailfrom")
   
    ' Who you're sending the email to.
    Mailer.FromName = session("namefrom")
   
    ' Put the email to send to, as well as the name of the person 
  Mailer.AddRecipient "DelawarePostcard Receiver", session("emailto")

    ' Subject of the email
    Mailer.Subject = "A //Delaware E-PostCard to " & session("nameto")

    ' Print the body of the email
    enviar = "Let me inform you that " & session("namefrom") & _
              Chr(13) & Chr(10) & _
              "has sent you a digital e-card from our website at www.delawaremusic.net. To see " & _
              "your postcard, follow the link :" & _
              Chr(13) & Chr(10) & Chr(13) & Chr(10) & _
              "http://www.delawaremusic.net/web/interact/webcard/view.asp?fromn=out&" & _
              "ident=" & identifier & _
              "&psw=" & passw & " " & Chr(13) & Chr(10) & Chr(13) &_
              " Your card is available till the day " & _ 
              formatDateTime(d,2) & _
              Chr(13) & Chr(10) & Chr(13) & Chr(10) & _
              Chr(13) & Chr(10) & _
              "        We hope you'll enjoy your card! <br> - the team at www.delawaremusic.net." 

    Mailer.BodyText = enviar

    'Just skip if there are any errors...
    On Error resume Next 

    ' This will send the email
    Mailer.Sendmail 


    ' Display an error message if there was an error
    If Err <> 0 Then %>
        <img src="images/error.gif" width="322" height="53" 
              border="0">
    <%
        'Comment out this code if you want to see
        'the error number
        'Response.Write "<br><br>" & "Error found : " & _                      Err.description & "<br><br>"

        Response.Write "<center><p>SERVER SIDE ERROR, " & _
                        "contact the site webmaster at webmaster@delawaremusic.net.</p></center>"

        goby = 0 
    Else
          Response.Write "<br><br><br><center><p>Your postcard has been sent, and there was " & _
                        "NO PROBLEMS...<br> See you later!"
    End if
End if

' I think that you have seen that I use the JavaScript history.back
' and go.  I use it so when the user come back he don't
' loose any information already entered into the form.
%>

<center>
    <a href="java script:history.go('-2')">
        <img src="images/rebuiltbutton.gif" width="60" 
              height="53" border="0">
    </a>
</center>
</strong></small></font>

</body>
</html>
Avatar billede lange Nybegynder
08. september 2002 - 23:37 #10
SQLStmt = "SELECT * FROM postal WHERE ID_POSTAL = " & _
    CInt(ident) & " AND passw = " & CInt(psw)

ident og/eller pas er ikke en integer.
Avatar billede knutbl Nybegynder
08. september 2002 - 23:49 #11
Og (nok en gang påpeker jeg at jeg ikke er noen racer ;-)) hvordan løser jeg problemet???

Beklager at jeg må ha det inn med teskje!

Kan noen gi meg en klar og tydelig beskjed om hva jeg må endre for å få dette til å fungere? Beklager hvis noen av dere føler at dere har gitt meg et klart og tydelig svar... Jeg bare ser det ikke! ;-)

KnB
Avatar billede lange Nybegynder
09. september 2002 - 00:41 #12
Du sender nogle værdier til scriptet via querystring. De værdier, der hedder ident og psw skal være tal - de må altså ikke indeholde numre.
Avatar billede stoney96 Nybegynder
09. september 2002 - 03:18 #13
Avatar billede eagleeye Praktikant
09. september 2002 - 07:57 #14
Prøv i filen  ENVIADO.ASP 

Efter denne linie  :
rs.Open SQLStmt, Conn

At tilføje:

identifier = rs("ident")
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester