Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp and Sql syntax 1

Status
Not open for further replies.

redsand

Programmer
Aug 15, 2001
45
0
0
US
I am trying to read an sql table, store Efficiency field value based on the Cellnum value. The stored field will populate a java param field
SQL TABLE
CellNum Cell Efficiency


SqlOP = "SELECT Efficiency,Cellnum,Cell from Efficiency"
'------------OPEN UP DATABASE AND RUN QUERY
conOP.open "dsn=Dashboard","xx","xx"

'Static, Readonly, Command
rsOP.open sqlOP, conOP, 3, 1, 1

The table is very small 20 records and I need to select store the value in efficiency based on the cellnum.

If rs("Cellnum") = 66 Then
SmallMachop = rs("Efficiency")
else
If rs("Cellnum") = 36 Then
SmallAssop = rs("Efficiency")

Java param
<param name=&quot;g3value&quot; value=&quot;<%= SmallMachop%>&quot;>
<param name=&quot;g2value&quot; value=&quot;<%= SmallAssop%>&quot;>

Is this the correct syntax. Is this the even the correct way to do this? Any help would be greatly appreciated. Happy Holidays

 
Try this:

Select Case rs(&quot;Cellnum&quot;)
Case 66
SmallMachop = rs(&quot;Efficiency&quot;)
Case 36
SmallAssop = rs(&quot;Efficiency&quot;)
End Select
 
I am getting invalid charater Case 66 Here is what I Have

SqlOP = &quot;SELECT Efficiency,Cellnum,Cell from Efficiency&quot;

'------------OPEN UP DATABASE AND RUN QUERY

conOP.open &quot;dsn=Dashboard&quot;,&quot;x&quot;,&quot;x&quot;


'Static, Readonly, Command
rsOP.open sqlOP, conOP, 3, 1, 1

'-----------CHECK FOR NULL RECORD SET

dataOPAvail = True
if rsOP.EOF and rsOP.BOF then
dataOPAvail = False
end if

'----------Get data for ontime

if dataOPAvail Then
Select Case rs(&quot;Cellnum&quot;)
   Case 66
   SmallMachop = rs(&quot;Efficiency&quot;)
  Case 36
   SmallAssop = rs(&quot;Efficiency&quot;)
End Select
else
SmallMachop = 0

end if
'-----------CLOSE CONNECTION AND RECORDSET OBJECTS

rsOP.close
Set rsOP = nothing
conOP.close
Set conOP = nothing

 
Never Mind, I had a syntax error with the rs - rsOP.

Thanks for all of your help!!!!
 
I take that back, I am still getting an invalid character for case 66
 
You can try to explicitly convert the rs(&quot;Cellnum&quot;) to a Lng like this:

Select Case CLng(rs(&quot;Cellnum&quot;))
Case 66
SmallMachop = rs(&quot;Efficiency&quot;)
Case 36
SmallAssop = rs(&quot;Efficiency&quot;)
End Select

or use strings:

Select Case CStr(rs(&quot;Cellnum&quot;))
Case &quot;66&quot;
SmallMachop = rs(&quot;Efficiency&quot;)
Case &quot;36&quot;
SmallAssop = rs(&quot;Efficiency&quot;)
End Select
 
I tried both ways, I am still getting invalid character for Case 061. In Sql I have the field defined as nvarchar. I tried to use a different field(Cell) and changed the 061 to &quot;Small Cell&quot; to select data and received the same error.


Any ideas suggestions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top