?
Solved

Getting an error in this code

Posted on 2004-04-28
17
Medium Priority
?
243 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

862 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