PDA

View Full Version : Sql problem??


twocool
04-23-2003, 10:03 AM
i got this problem where i execute the sql it shows

EXEC UpdateApprove 'RQ2003040003, RQ2003040005','2, 2',''


but i want it this way... EXEC UpdateApprove 'RQ2003040003', 'RQ2003040005','2', '2',

this is my code... hope u all can give me an advise....

approve_request.asp
<script language="javascript">
<!--
function submit_form(ReqNo,ReqStatus,RejRemarks,action)
{
document.form2.ReqNo.value = ReqNo;
document.form2.ReqStatus.value = ReqStatus;
document.form2.RejRemarks.value = RejRemarks;
document.form2.dataAction.value = action;
document.form2.submit();
}
//-->
</script>

<% sql= "SELECT * from Requests WHERE ReqtrEmail = '"&Request.ServerVariables("LOGON_USER")&"@singtel.com' "
set rs = MSCS.Execute(sql)%>

<form name="form2" method="post" action="approve_action.asp">
<table width="100%" border="0" cellspacing=0 align="center">
<%Do While Not rs.EOF%>
<tr style="background-color:#EEEEEE;" class="header3">
<td width="15%" height="22">Request No</td>
<td width="25%" height="22">Requestor Name</td>
<td width="15%" height="22">Application System</td>
<td width="20%" height="22">Request Title</td>
<td width="10%" height="22">Request Date</td>
<td width="10%" height="22">Desired Date</td>
<td width="15%" height="22">Action</td>
</tr>

<tr style="background-color:#FFFFCC;" onmouseover="this.style.backgroundColor='#ffcc99';" onmouseout="this.style.backgroundColor='#FFFFCC';" class="text">

<td width="15%"><a href="approve_display.asp?ReqNo=<%=rs("ReqNo")%>" target="_blank", width=500,height=400><%=rs("ReqNo")%></a></td>
<input type="hidden" name="ReqNo" value="<%=rs("ReqNo")%>">
<td width="25%"><span class="txtblack12"><%=rs("Reqtr")%></span></td>

<td width="15%"><span class="txtblack12"><%=rs("AppnId")%></span></td>

<td width="20%"><span class="txtblack12"><%=rs("ReqTitle")%></span></td>

<td width="10%"><span class="txtblack12"><%=Day(rs("ReqDt") )%> /<%=Month(rs("ReqDt") )%> /<%=Year(rs("ReqDt") )%> <%'=rs("ReqDt")%></span></td>

<td width="10%"><span class="txtblack12"><%=Day(rs("DesiredDt") )%> /<%=Month(rs("DesiredDt") )%> /<%=Year(rs("DesiredDt") )%> <%'=rs("DesiredDt")%></span></td>

<td width="15%">
<select name = "ReqStatus">
<option value="2" <%if trim(rs("ReqStatus")) = "2" then%>selected<%end if%>>Approve</option>
<option value="98" <%if trim(rs("ReqStatus")) = "98" then%>selected<%end if%>>Reject</option>
</select>
</td>
</tr>

<tr>
<td width="15%">Reasons For Rejection:</td>
<td width="25%">
<textarea rows="3" cols="45" name="RejRemarks_<%=ReqNo%>" onKeyUp="max_count();" class="txtblack12"></textarea>
</td>
<td width="13%">
<input type="submit" onclick="javascript:submit_form('<%=ReqNo%>','<%=ReqStatus%>','<%=RejRemarks%>','update')" name=Submit value="Submit">
<!--input type="submit" name="Submit" value="Submit"-->
</td>
</tr>
<%rs.MoveNext%>
<%loop%>

</table></form>
<%
rs.close
set rs=nothing
%>

approve_action.asp

<%

'vAppnId = Request("AppnId")
'vReqStatus = Request("ReqStatus")
'vRejRemarks = Request("RejRemarks")
%>

<%
vReqNo = Request("ReqNo")

sql="SELECT * from Requests WHERE ReqNo = '" & vReqNo & "'"
set rs = MSCS.Execute(sql)
rs.close
set rs=nothing


sql="EXEC UpdateApprove '" & vReqNo & "','" &_
trim(Request("ReqStatus")) & "','" &_
trim(Request("RejRemarks")) & "'"
MSCS.execute(sql)

Response.Write sql
Response.End

'redirecturl = "approve_request.asp"
%>


pls help.. i having problem with this..... :(

raf
04-23-2003, 07:29 PM
Hmm.

Maybe try

sql="EXEC UpdateApprove '" + vReqNo + "','" + trim(Request("ReqStatus")) + "','" + trim(Request("RejRemarks")) + "'"

Just give it a try. Might work.

twocool
04-24-2003, 06:23 AM
its showing the same result...

EXEC UpdateApprove 'RQ2003040003, RQ2003040005','2, 2',''

i think it something to do with the approve_request.asp

pls help...... i really need ur advice..

glenngv
04-24-2003, 07:24 AM
vReqNo = Request("ReqNo")
if vReqNo<>"" then vReqNo = replace(vReqNo,",","','")
...
sql="EXEC UpdateApprove '" & vReqNo & "','" &_
trim(Request("ReqStatus")) & "','" &_
trim(Request("RejRemarks")) & "'"
MSCS.execute(sql)

twocool
04-24-2003, 11:51 AM
EXEC UpdateApprove 'RQ2003040003',' RQ2003040017','REJECTED',' APPROVED','test',' '


it comes out... but... i jst have to submit one req no but in the end.. its sumbits bth of req no........ when i clikc on the submit button

how to solve this.....

pls advise me..... :(

twocool
04-25-2003, 03:13 AM
when i click the submit button....... the execute the sql and shows this

EXEC UpdateApprove 'RQ2003040003',' RQ2003040017','APPROVED',' APPROVED','',' '

actually each req no has one submit button..... however.... it submits all the request no found the that page.. need yr help and advise..

this is my editted codes

approve_request.asp

<script language="javascript">
<!--
function submit_form(ReqNo,ReqStatus,RejRemarks,action)
{
document.form2.ReqNo.value = ReqNo;
document.form2.ReqStatus.value = ReqStatus;
document.form2.RejRemarks.value = RejRemarks;
document.form2.submit();
}
//-->
</script>

<% sql= "SELECT * from Requests WHERE ReqtrEmail = '"&Request.ServerVariables("LOGON_USER")&"@singtel.com' "
set rs = MSCS.Execute(sql)%>

<form name="form2" method="post" action="approve_action.asp">
<table width="100%" border="0" cellspacing=0 align="center">
<%Do While Not rs.EOF%>
<tr style="background-color:#EEEEEE;" class="header3">
<td width="15%" height="22">Request No</td>
<td width="25%" height="22">Requestor Name</td>
<td width="15%" height="22">Application System</td>
<td width="20%" height="22">Request Title</td>
<td width="10%" height="22">Request Date</td>
<td width="10%" height="22">Desired Date</td>
<td width="15%" height="22">Action</td>
</tr>

<tr style="background-color:#FFFFCC;" onmouseover="this.style.backgroundColor='#ffcc99';" onmouseout="this.style.backgroundColor='#FFFFCC';" class="text">

<td width="15%"><a href="approve_display.asp?ReqNo=<%=rs("ReqNo")%>" target="_blank", width=500,height=400><%=rs("ReqNo")%></a></td>
<input type="hidden" name="ReqNo" value="<%=rs("ReqNo")%>">
<td width="25%"><span class="txtblack12"><%=rs("Reqtr")%></span></td>

<td width="15%"><span class="txtblack12"><%=rs("AppnId")%></span></td>

<td width="20%"><span class="txtblack12"><%=rs("ReqTitle")%></span></td>

<td width="10%"><span class="txtblack12"><%=Day(rs("ReqDt") )%> /<%=Month(rs("ReqDt") )%> /<%=Year(rs("ReqDt") )%> <%'=rs("ReqDt")%></span></td>

<td width="10%"><span class="txtblack12"><%=Day(rs("DesiredDt") )%> /<%=Month(rs("DesiredDt") )%> /<%=Year(rs("DesiredDt") )%> <%'=rs("DesiredDt")%></span></td>


<td width="15%">
<select name = "ReqStatus">
<option value="APPROVED" <%if trim(rs("ReqStatus")) = "2" then%>selected<%end if%>>Approve</option>
<option value="REJECTED" <%if trim(rs("ReqStatus")) = "98" then%>selected<%end if%>>Reject</option>
</select>
</td>
</tr>

<tr>
<td width="15%">Reasons For Rejection:</td>
<td width="25%">
<textarea rows="3" cols="45" name="RejRemarks" onKeyUp="max_count();" class="txtblack12"></textarea>
</td>
<td width="13%">
<input type="submit" onclick="javascript:submit_form('<%=ReqNo%>','<%=ReqStatus%>','<%=RejRemarks%>','update')" name=Submit value="Submit">
<!--input type="submit" name="Submit" value="Submit"-->
</td>
</tr>
<%rs.MoveNext%>
<%loop%>

</table></form>
<%
rs.close
set rs=nothing
%>


approve_action.asp

<%
vReqStatus = Request("ReqStatus")
vRejRemarks = Request("RejRemarks")
vReqNo = Request("ReqNo")
if vReqNo <>"" then vReqNo = replace(vReqNo,",","','")
if vReqStatus <>"" then vReqStatus = replace(vReqStatus,",","','")
if vRejRemarks <>"" then vRejRemarks = replace(vRejRemarks,",","','")

sql="EXEC UpdateApprove '" + vReqNo + "','" + vReqStatus + "','" + vRejRemarks + "'"

Response.Write sql
Response.End

'redirecturl = "approve_request.asp"
%>