Solved

Getting an error in this code

Posted on 2004-04-28
17
236 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Filter Question 8 86
Query to get the soonest date out of a few records 2 51
Auto Submit on dropdown box 14 72
Classic ASP - problem with MS SQL Select Query? 10 60
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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