Solved

Why is my code not working?

Posted on 2004-10-13
15
225 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now