Solved

Getting an error in this code

Posted on 2004-04-28
17
233 Views
Last Modified: 2006-11-17
Microsoft VBScript runtime error '800a000d'

Type mismatch

/stafftransactioneditpending.asp, line 39
line 39 is identified by <_____----------- this below

<html>

<head>
<title>New Page 1</title>
</head>
<%
r = Request.Form("R1")
If r = Active then
'Dimension variables
Dim adoCon                   'Holds the Database Connection Object
Dim rsAddComments      'Holds the recordset for the new record to be added to the database
Dim strSQL                  'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
ID=Request.Querystring("ID")
'Set an active connection to the Connection object using a DSN-less connection

set Conn = Server.CreateObject("ADODB.Connection")
adoCon.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=F:\hshome\ctinter\Data\ctinter.mdb"

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL  = "select * from T_Transaction where Transaction_ID = " & ID & ";"

rsAddComments.CursorType = 2
rsAddComments.LockType = 3

rsAddComments.Open strSQL, adoCon
rsAddComments("Status") =  r
rsAddComments("ChangeStatusDate") =  date()
Response.Redirect "congratulation.asp"
else
rsAddComments("requestchangeStatus") =  r  <_____----------------------------------
rsAddComments("requestchangedate") =  date()
Response.Redirect "Changerequest.asp"
end if
%>
<body>

</body>
<%
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
%>
</html>
0
Comment
Question by:eteran
  • 9
  • 4
  • 4
17 Comments
 
LVL 7

Expert Comment

by:chisholmd
ID: 10945709
What is the datatype of :
   rsAddComments("requestchangeStatus")
bit? int?

Does the value of Request.Form("R1") make a difference in the error?

I would write r out to the screen first to make sure it is what you think it is.

Then if your field is an int, try a cint(r)

btw: you load up this rs with values then redirect somewhere else befor calling an update method, so you are not doing anything.  You might find it more efficient to use an update statement and bypass the rs altogether "update table set field=value where something=something"

better yet if your using ms sql use stored procedure and stay away from security riddled dynamic sql.




0
 

Author Comment

by:eteran
ID: 10945725
r prints out active or dropped
0
 

Author Comment

by:eteran
ID: 10945756
not useing SQl. I do not understand why it is not wokring
0
 

Author Comment

by:eteran
ID: 10945845
anyone
0
 
LVL 7

Expert Comment

by:chisholmd
ID: 10945863
Sorrey eteran but when you say "r prints out active or dropped" do you mean

"active" or "dropped" as strings ?

or a numbered value such as 1 or 0 ?

And what is the datatype of the field in the database?

With respect, are you familiar with the term "data type"

If the database field rsAddComments("requestchangeStatus")
is defined as an interger or number field of some sort and you try to store a string (character data) in it, then you would get a data type error like the one you are getting.




0
 

Author Comment

by:eteran
ID: 10945896
date type is text in the database. the value prints Active or dropped as a string.  
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 10945909
helloo

This is the problem with data type of the database field and the value you are trying to enter..

Check out the datafield data type..

As in your last comment, value for r is active or dropped, it means 'rsAddComments("requestchangeStatus")' should be a text or varchar field.. if it is not then you need to derive a acceptable value for the data field from the value of r..

I guess it will help you.. or else plz let me know.. the data type of data field... so that i can epxlain you how to handle this..

neeraj523


0
 

Author Comment

by:eteran
ID: 10945910
The below is the form that the user inputs the info the values are postedbelow this script is the page to check everything    
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
      <tr>
        <td width="24%">
        <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#CBDAB6" width="100%" bgcolor="#CBDAB6">
          <tr>
            <td width="100%"><b><font face="Arial" size="2" color="#6A6B56">
            Change Transaction status</font></b></td>
          </tr>
        </table>
        </td>
        <td width="76%">&nbsp;</td>
      </tr>
      <tr>
        <td width="100%" colspan="2">
        <form method="POST" action="stafftransactioneditpending.asp?id=<%=Request.Querystring("ID")%>">
         <p>&nbsp;</p>
          <p><b><font face="Arial"><input type="radio" value="Active" name="R1"><font size="2">
          Change to an Active Transaction </font></font></b></p>
          <p><b><font face="Arial">
          <input type="radio" value="Dropped" name="R1"><font size="2">Change
          to a Dropped transaction </font></font></b></p>
          <p align="center"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
        </form>
        </td>
      </tr>
      <tr>
        <td width="100%" colspan="2">&nbsp;</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td width="100%">&nbsp;</td>
  </tr>
  <tr>
    <td width="100%">&nbsp;</td>
  </tr>
</table>

Link page

<html>

<head>
<title>New Page 1</title>
</head>
<%
r = Request.Form("R1")
response.write r
If r = Active then
'Dimension variables
Dim adoCon                   'Holds the Database Connection Object
Dim rsAddComments      'Holds the recordset for the new record to be added to the database
Dim strSQL                  'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
ID=Request.Querystring("ID")
'Set an active connection to the Connection object using a DSN-less connection

set Conn = Server.CreateObject("ADODB.Connection")
adoCon.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=F:\hshome\ctinter\Data\ctinter.mdb"

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL  = "select * from T_Transaction where Transaction_ID = " & ID & ";"

rsAddComments.CursorType = 2
rsAddComments.LockType = 3

rsAddComments.Open strSQL, adoCon

rsAddComments("Status") =  r
rsAddComments("ChangeStatusDate") =  date()
rsAddComments.Update
Response.Redirect "congratulation.asp"

else

'rsAddComments("requestchangeStatus") =  r
'rsAddComments("requestchangedate") =  date()
'rsAddComments.Update
Response.Redirect "Changetodroppedrequest.asp"

end if
%>
<body>

</body>
<%
Set adoCon = Nothing
Set strCon = Nothing
Set rsAddComments = Nothing
%>
</html>


0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 22

Expert Comment

by:neeraj523
ID: 10945915

hmmm

try to use this

rsAddComments("requestchangeStatus") =  cStr(r)


neeraj523
0
 

Author Comment

by:eteran
ID: 10945935
here is what is what I am not understanding. I worte an if statement. Even if if R is avtive it jumps to the else???? I think that is the error.
0
 
LVL 7

Expert Comment

by:chisholmd
ID: 10945978
Ok but I asked a few specific questions, if you don't address them I can't help you.
0
 

Author Comment

by:eteran
ID: 10945998
active" or "dropped" as strings ?  Yeah if you look at the code it is a string

or a numbered value such as 1 or 0 ? No they are numeric

And what is the datatype of the field in the database? The datetype in the datebase is set to text

With respect, are you familiar with the term "data type"? Yes I am familiar with data type
 
0
 

Author Comment

by:eteran
ID: 10946014
okay I forced it through I set r = active and it works so it has to be the request.form. request.form is looking for the value of the radio button would that effect anyhting

       <p><b><font face="Arial"><input type="radio" value="Active" name="R1"><font size="2">
          Change to an Active Transaction </font></font></b></p>
          <p><b><font face="Arial">
          <input type="radio" value="Dropped" name="R1"><font size="2">
0
 
LVL 7

Accepted Solution

by:
chisholmd earned 500 total points
ID: 10946088
Aha! I see your problem.

Your line;
If r = Active then
needs to be:
If r = "Active" then
'note the quotes

then you have another problem, you define the rs within the "if" portion but then you try to assign values to it in within your else block, but the rs doesnot exist

if...
    define recordest
else
    try to assign value to rs field
end if

If the if statement is not true you never define the recordset but try to assign values to it.

do this instead:

define recordest
if...
  set field values
else
  set other field values  
end if

dave


 

0
 
LVL 22

Expert Comment

by:neeraj523
ID: 10946109

try this

=================================
r = trim(Request.Form("R1"))
If r = "Active" then
End if

=================================

r is a string and you can't compare it like r=Active

neeraj523
0
 

Author Comment

by:eteran
ID: 10946111
Amazing...good job
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 10946148

ooops.. sorry.. i wrote same what chisholmd already written..

sorry i was bit late...

neeraj523
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now