I am using Dreamweaver MX 2004 with JSP/sybase. I am trying to setup a
variable in my recordset for a field that is a smallint in my database. If I
set the runtime variable to request.getParameter(weekNbr) I can successfully
test the query. (Note that I have to leave out the quotes). If I put the
quotes in, I receive a convert message. Either way I am unable to make this
work. I realize that DW is converting to a string, but how can I edit the code
to prevent this? I appreciate any help you can provide. Is my only option to
set the database field type as varchar? Michelle

<%@ page contentType="text/html; charset=iso-8859-1" language="java"
import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="Connections/connSurvery.jsp" %>
<%
String rsTime__MMColParam = "hagarm";
if (request.getParameter("MM_EmptyValue") !=null) {rsTime__MMColParam =
(String)request.getParameter("MM_EmptyValue");}
%>
<%
String rsTime__nbrweek = "1";
if (request.getParameter(weekNbr) !=null) {rsTime__nbrweek =
(String)request.getParameter(weekNbr);}
%>
<%
Driver DriverrsTime =
(Driver)Class.forName(MM_connSurvery_DRIVER).newIn stance();
Connection ConnrsTime =
DriverManager.getConnection(MM_connSurvery_STRING, MM_connSurvery_USERNAME,MM_con
nSurvery_PASSWORD);
PreparedStatement StatementrsTime = ConnrsTime.prepareStatement("SELECT *
FROM dbo.IA_timeSurvey_Hours WHERE MNA = '" + rsTime__MMColParam + "' AND
weekNbr = " + rsTime__nbrweek + "");
ResultSet rsTime = StatementrsTime.executeQuery();
boolean rsTime_isEmpty = !rsTime.next();
boolean rsTime_hasData = !rsTime_isEmpty;
Object rsTime_data;
int rsTime_numRows = 0;
%>
<%
Driver DriverrsWeek =
(Driver)Class.forName(MM_connSurvery_DRIVER).newIn stance();
Connection ConnrsWeek =
DriverManager.getConnection(MM_connSurvery_STRING, MM_connSurvery_USERNAME,MM_con
nSurvery_PASSWORD);
PreparedStatement StatementrsWeek = ConnrsWeek.prepareStatement("SELECT
convert(char(20),weekStartDate,101) As startDate,
convert(char(20),weekEndDate,101) As endDate, weekNbr FROM
dbo.IA_timeSurvey_Weeks");
ResultSet rsWeek = StatementrsWeek.executeQuery();
boolean rsWeek_isEmpty = !rsWeek.next();
boolean rsWeek_hasData = !rsWeek_isEmpty;
Object rsWeek_data;
int rsWeek_numRows = 0;
%>
<%
int Repeat1__numRows = -1;
int Repeat1__index = 0;
rsTime_numRows += Repeat1__numRows;
%>
<% String MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and
Form parameters

String MM_keepBoth,MM_keepURL="",MM_keepForm="",MM_keepNo ne="";
String[] MM_removeList = { "index", MM_paramName };

// create the MM_keepURL string
if (request.getQueryString() != null) {
MM_keepURL = '&' + request.getQueryString();
for (int i=0; i < MM_removeList.length && MM_removeList[i].length() != 0;
i++) {
int start = MM_keepURL.indexOf(MM_removeList[i]) - 1;
if (start >= 0 && MM_keepURL.charAt(start) == '&' &&
MM_keepURL.charAt(start + MM_removeList[i].length() + 1) == '=') {
int stop = MM_keepURL.indexOf('&', start + 1);
if (stop == -1) stop = MM_keepURL.length();
MM_keepURL = MM_keepURL.substring(0,start) + MM_keepURL.substring(stop);
}
}
}

// add the Form variables to the MM_keepForm string
if (request.getParameterNames().hasMoreElements()) {
java.util.Enumeration items = request.getParameterNames();
while (items.hasMoreElements()) {
String nextItem = (String)items.nextElement();
boolean found = false;
for (int i=0; !found && i < MM_removeList.length; i++) {
if (MM_removeList[i].equals(nextItem)) found = true;
}
if (!found && MM_keepURL.indexOf('&' + nextItem + '=') == -1) {
MM_keepForm = MM_keepForm + '&' + nextItem + '=' +
java.net.URLEncoder.encode(request.getParameter(ne xtItem));
}
}
}

String tempStr = "";
for (int i=0; i < MM_keepURL.length(); i++) {
if (MM_keepURL.charAt(i) == '<') tempStr = tempStr + "&lt;";
else if (MM_keepURL.charAt(i) == '>') tempStr = tempStr + "&gt;";
else if (MM_keepURL.charAt(i) == '"') tempStr = tempStr + "&quot;";
else tempStr = tempStr + MM_keepURL.charAt(i);
}
MM_keepURL = tempStr;

tempStr = "";
for (int i=0; i < MM_keepForm.length(); i++) {
if (MM_keepForm.charAt(i) == '<') tempStr = tempStr + "&lt;";
else if (MM_keepForm.charAt(i) == '>') tempStr = tempStr + "&gt;";
else if (MM_keepForm.charAt(i) == '"') tempStr = tempStr + "&quot;";
else tempStr = tempStr + MM_keepForm.charAt(i);
}
MM_keepForm = tempStr;

// create the Form + URL string and remove the intial '&' from each of the
strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length() > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length() > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length() > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Time Survey</title>
</head>

<body>
<p><img src="images/top.gif" width="549" height="59">
</p>
<form name="form1" method="post" action="">
<p>&nbsp; </p>
<p> Select Week Beginning on:
<A HREF="time.jsp?<%= MM_keepForm + ((MM_keepForm!="")?"&":"") +
"weekNbr=" + (((rsWeek_data = rsWeek.getObject("weekNbr"))==null ||
rsWeek.wasNull())?"":rsWeek_data) %>">
<select name="selectWeek" id="selectWeek">
<option value=" "></option>
<%
while (rsWeek_hasData) {
%>
<option
value="<%=((rsWeek.getObject("weekNbr")!=null)?rsW eek.getObject("weekNbr"):"")%>
"><%=((rsWeek.getObject("startDate")!=null)?rsWeek .getObject("startDate"):"")%><
/option>
<%
rsWeek_hasData = rsWeek.next();
}
rsWeek.close();
rsWeek = StatementrsWeek.executeQuery();
rsWeek_hasData = rsWeek.next();
rsWeek_isEmpty = !rsWeek_hasData;
%>
</select>
</A>
</p>

<% if (!rsTime_isEmpty ) { %>
<table width="721" border="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>Univ</td>
<td>MUHA</td>
<td>UMA</td>
<td>HSF</td>
<td>FRD</td>
<td>AHEC</td>
<td>CFC</td>
<td>Sick/Vac Other </td>
<td>&nbsp;</td>
</tr>
<% while ((rsTime_hasData)&&(Repeat1__numRows-- != 0)) { %>
<tr>
<td width="21">&nbsp;</td>
<td width="34"><%=(((rsTime_data = rsTime.getObject("dayOfWeek"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="46"><%=(((rsTime_data = rsTime.getObject("hoursUNIV"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="58"><%=(((rsTime_data = rsTime.getObject("hoursMUHA"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="51"><%=(((rsTime_data = rsTime.getObject("hoursUMA"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="43"><%=(((rsTime_data = rsTime.getObject("hoursHSF"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="42"><%=(((rsTime_data = rsTime.getObject("hoursFRD"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="53"><%=(((rsTime_data = rsTime.getObject("hoursAHEC"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="38"><%=(((rsTime_data = rsTime.getObject("hoursCFC"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="77"><%=(((rsTime_data = rsTime.getObject("hoursOther"))==null
|| rsTime.wasNull())?"":rsTime_data)%></td>
<td width="215">&nbsp;</td>
</tr>
<%
Repeat1__index++;
rsTime_hasData = rsTime.next();
}
%>
</table>
<% } /* end !rsTime_isEmpty */ %>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<%
rsTime.close();
StatementrsTime.close();
ConnrsTime.close();
%>
<%
rsWeek.close();
StatementrsWeek.close();
ConnrsWeek.close();
%>