Solved

Why is my code not working?

Posted on 2004-10-13
15
229 Views
Last Modified: 2012-08-13
Seems to be a simple enough problem but I am unable to get the correct results. The erring line is as below:

<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%if ((myRS("Release")=0) or (Trim(myRS("Release")) = "") or isNull(myRS("Release"))) then Response.Write "checked" end if%> >No

Its giving me the error

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: " "]'

Please help!!

A.
0
Comment
Question by:arunatata
  • 5
  • 4
  • 3
  • +3
15 Comments
 
LVL 5

Expert Comment

by:waelothman
ID: 12303840
<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%if ((myRS("Release")="") or (Trim(myRS("Release")) = "") or isNull(myRS("Release"))) then Response.Write "checked" end if%> >No

myRS("Release") seems to be string
0
 
LVL 5

Expert Comment

by:waelothman
ID: 12303847
you can't compare string with numeric (0)
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 12303858
Hi

try with quotes around the 0 like so

<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%if ((myRS("Release")="0") or (Trim(myRS("Release")) = "") or isNull(myRS("Release"))) then Response.Write "checked" end if%> >No

as 0 it is an integer but as "0" it is a string

HTH

Scott
0
Industry Leaders: 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:arunatata
ID: 12303908
I did that with another - using value="1" - and that worked. For some reason it doesn't like the value " " in the database. If I have 0 or 1 or Null in the database it works fine...only for the spaces or blanks it has problems.

A.
0
 

Author Comment

by:arunatata
ID: 12303918
I tried with the quotes around the "0" and that didn't work either.
0
 
LVL 5

Expert Comment

by:waelothman
ID: 12304053
<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%if ((cint(myRS("Release"))=0) or (Trim(myRS("Release")) = "") or isNull(myRS("Release"))) then Response.Write "checked" end if%> >No
0
 

Author Comment

by:arunatata
ID: 12304080
Not that either. As i mentioned in my post above - the problem is with the blank spaces - not the 0 or 1 or Null values in the database. I've verified with all three and only the spaces is giving me an error.
0
 
LVL 5

Assisted Solution

by:waelothman
waelothman earned 150 total points
ID: 12304222
it is not in database  ASp not allow you to compare string with number
 myrec("fieldname") always catched as string even if the field is numeric
0
 
LVL 10

Expert Comment

by:m8rix
ID: 12304336
Hi arunatata,

waelothman is correct, you can't compare string with numeric (0) however here is some code to replace what you currently have, it is a bit longer, but it is the only way... and it WILL fix your problem.

Cheers!

<%
strdatabase = " "
IsZero = false
If isNumeric(strdatabase) Then
      If strdatabase = 0 Then IsZero = true
End If
%>
<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%if (IsZero) or (Trim(strdatabase) = "") or (isNull(strdatabase)) then Response.Write "checked" end if%> >No
0
 
LVL 10

Accepted Solution

by:
m8rix earned 350 total points
ID: 12304350
Oops! sorry arunatata, I posted you the code that I used for testing... here is the modified version of your code:

<%
IsZero = false
If isNumeric(myRS("Release")) Then
      If myRS("Release") = 0 Then IsZero = true
End If
%>
<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%if (IsZero) or (Trim(myRS("Release")) = "") or isNull(myRS("Release"))) then Response.Write "checked" end if%> >No
0
 

Author Comment

by:arunatata
ID: 12304427
Nope - that doesn't work either. I am posting the entire page below - maybe something here will strike out as wrong..


<%@ Language=VBScript %>
<%Response.Buffer = "true"%>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</head>
<body>
<form action="SearchResultsUpdateData.asp" Method="Post" id="form5" name="form5">
<%
PONumber = Request("PONumber")
Output = Request("Output")
Key1 = request("Key1")

Dim myConn                  
Dim myRS                  
Dim myRS1
Dim stmt            
Dim DText            
Dim i            

Set myRS = Server.CreateObject("ADODB.Recordset")
Set myRS1= Server.CreateObject("ADODB.Recordset")
Set myConn = Server.CreateObject("ADODB.Connection")
DText="Provider=SQLOLEDB;Server=abc;Initial Catalog=sand;User ID=sa"
myConn.Open DText
stmt1 = "select * from DesignMain where [PO Number] = '"&PONumber&"'"      
myRS1.Open stmt1, myConn,1,3
stmt = "Select * from BoardDesignYN where [PO Number] = '"&PONumber&"'"
myRS.Open stmt,myConn,1,3

IsZero = False

if isNumeric(myRS("Release to Production")) then
      if myRS("Release to Production") = 0 then
           IsZero = True
      end if
end if
%>


<td><b>Net List</b>
<input TYPE="radio" NAME="NetList" value="1" <%if (myRS("Net List"))=1 then Response.Write "Checked" end if%>>Yes
<input TYPE="radio" NAME="NetList" value="0" <%if (myRS("Net List"))=0 then Response.Write "Checked" end if%>>No</td>
</tr><br>
<% 'The section above works fine. I didn't have to go through any integer or string conversions for this.

'The section below is the problem area.
%>


<td><b>Release to Production?</b>
<input TYPE="radio" NAME="Release" value="1" <%if (myRS("Release To Production"))=1 then Response.Write "Checked" end if%>>Yes
<input TYPE="radio" NAME="Release" value="0" <%if ((IsZero) or (Trim(myRS("Release to Production")) = "") or isNull(myRS("Release to Production"))) then Response.Write "checked" end if%>>No
</td>
</tr>




<tr><td align="center" colspan="2"><input TYPE="submit" VALUE="Update" id="submit" name="submit"></td></tr>


</table>

<%      
myRS.Close
set myRS=nothing
%>


</table>



</form>

</body>
</html>
0
 
LVL 10

Expert Comment

by:m8rix
ID: 12304814
Ok forget what I suggested before, try replacing this WHOLE section:

<td><b>Net List</b>
<input TYPE="radio" NAME="NetList" value="1" <%if (CStr(myRS("Net List"))="1") then Response.Write "Checked" end if%>>Yes
<input TYPE="radio" NAME="NetList" value="0" <%if (Cstr(myRS("Net List"))="0") then Response.Write "Checked" end if%>>No</td>
</tr><br>
<% 'The section above works fine. I didn't have to go through any integer or string conversions for this.

'The section below is the problem area.
%>


<td><b>Release to Production?</b>
<input TYPE="radio" NAME="Release" value="1" <%if (CStr(myRS("Release To Production"))="1") then Response.Write "Checked" end if%>>Yes
<input TYPE="radio" NAME="Release" value="0" <%if (CStr(myRS("Release to Production"))="1") or (Trim(CStr(myRS("Release to Production"))) = "") or isNull(myRS("Release to Production")) then Response.Write "checked" end if%>>No
</td>
</tr>
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12305392
what is the datatype of field "release to production" and try len(trim(myRs("Release to production")) = 0 instead of ltrim(myRs("Release to production") = ""
0
 
LVL 3

Expert Comment

by:Kupi
ID: 12305913
What about this?

<input TYPE="radio" NAME="ReleaseToProduction" value="0" <%If CInt("0" & Trim(myRS("Release"))) = 0 Then Response.Write "checked" End If%>>No

This combines all your conditions (= 0, = "", = NULL) in one.

Kupi
0
 
LVL 5

Expert Comment

by:waelothman
ID: 12306364
please     if myRS("Release to Production") = "0" then
as well as in all code
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
Bypass cross origin issues on development site 3 95
Issues with Insert statement 12 31
Html form and modal / img src -problem 3 45
2012 SQL to JSON Select 5 31
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 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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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