?
Solved

Getting an error in this code

Posted on 2004-04-28
17
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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