Ask a Question related to Dreamweaver AppDev, Design and Development.
-
mchagar #1
JSP smallint variable
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 + "<";
else if (MM_keepURL.charAt(i) == '>') tempStr = tempStr + ">";
else if (MM_keepURL.charAt(i) == '"') tempStr = tempStr + """;
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 + "<";
else if (MM_keepForm.charAt(i) == '>') tempStr = tempStr + ">";
else if (MM_keepForm.charAt(i) == '"') tempStr = tempStr + """;
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> </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> </td>
<td> </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> </td>
</tr>
<% while ((rsTime_hasData)&&(Repeat1__numRows-- != 0)) { %>
<tr>
<td width="21"> </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"> </td>
</tr>
<%
Repeat1__index++;
rsTime_hasData = rsTime.next();
}
%>
</table>
<% } /* end !rsTime_isEmpty */ %>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</form>
<p> </p>
<p> </p>
</body>
</html>
<%
rsTime.close();
StatementrsTime.close();
ConnrsTime.close();
%>
<%
rsWeek.close();
StatementrsWeek.close();
ConnrsWeek.close();
%>
mchagar Guest
-
#39634 [NEW]: session variable and normal variable
From: erhanbaris at gmail dot com Operating system: Win Xp SP1 PHP version: 5.2.0 PHP Bug Type: Variables related Bug... -
#39251 [NEW]: variable variable class array property is read only
From: taskfreak at gmail dot com Operating system: mac os PHP version: 5.1.6 PHP Bug Type: Class/Object related Bug... -
#22237 [Com]: PHP crashes when class references property using variable variable
ID: 22237 Comment by: rep at devdomain dot com Reported By: peter at globalvision dot com dot au Status: Closed... -
passing javascript variable into asp variable using vbscript
The subject pretty much sums up what I need to do. Here is what I have so far, but still can't figure out how to get it working: <script... -
Datalist - how (if) to use a sub variable or session variable in the footer?
Hi, sorry to be greedy with all my posts lately, but can you tell I'm doing new things this week? I've just done my first datalist (a simple...



Reply With Quote

