Getting an error in this code

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>
eteranAsked:
Who is Participating?
 
chisholmdConnect With a Mentor Commented:
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
 
chisholmdCommented:
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
 
eteranAuthor Commented:
r prints out active or dropped
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
eteranAuthor Commented:
not useing SQl. I do not understand why it is not wokring
0
 
eteranAuthor Commented:
anyone
0
 
chisholmdCommented:
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
 
eteranAuthor Commented:
date type is text in the database. the value prints Active or dropped as a string.  
0
 
neeraj523Commented:
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
 
eteranAuthor Commented:
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
 
neeraj523Commented:

hmmm

try to use this

rsAddComments("requestchangeStatus") =  cStr(r)


neeraj523
0
 
eteranAuthor Commented:
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
 
chisholmdCommented:
Ok but I asked a few specific questions, if you don't address them I can't help you.
0
 
eteranAuthor Commented:
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
 
eteranAuthor Commented:
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
 
neeraj523Commented:

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
 
eteranAuthor Commented:
Amazing...good job
0
 
neeraj523Commented:

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

sorry i was bit late...

neeraj523
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.