This document was generated from CDN thread
Created by: Cindy Brozyno on 27-12-2011 12:51:04 PM
I am writing a time clock app; this part of the code checks last transaction for type (in/out) so they don't try to punch in w/o punching out, or vice versa.
Working with the clock out routine.
Successful IF there is a previous record in the database; however, if this is their first transaction, I am unable to resolve.
Please review code below and see if you can identify a solution. Any help is GREATLY appreciated.
Cindy
//Is the person is trying to punch out w/o punching in?
var input=Request.QueryString("input"); //comes from the Phone Input (previous page)
var Conn = Server.CreateObject("ADODB.Connection");
var RS = Server.CreateObject("ADODB.Recordset");
var sql2;
var str;
Conn.Open("Provider=SQLNCLI10;Data Source=xxx;Persist Security Info=False;Initial Catalog=IPTimeClock;Uid=xxx;Pwd=xxx;");
sql2=("SELECT Type FROM dbo.tblTransactions WHERE TransID=(SELECT MAX(TransID)from dbo.tblTransactions WHERE UserID="+input+")");
RS.CursorType=2;
RS.Open(sql2, Conn);
str=RS("Type");
if (RS.EOF == true and RS.BOF == true)
{
Clockout(input);
}else
{
RS.MoveFirst();
if (str="O")
{
Response.Write("<CiscoIPPhoneText>\r\n");
Response.Write("<Title>IP Time Clock</Title>");
Response.Write("<Text>You are currently clocked OUT.\r\n Please Clock In First.</Text>\r\n");
Response.Write("</CiscoIPPhoneText>\r\n");
}
else{Clockout(input);}
}
//RS.close;
//Conn.close;
//RS=null;
//Conn=null;
Subject: RE: ADO Select query problem
Replied by: Florian Kroessbacher on 28-12-2011 04:43:46 AM
Hy Cindy,
What about to count this here
"SELECT Type FROM dbo.tblTransactions WHERE TransID=(SELECT MAX(TransID)from dbo.tblTransactions WHERE UserID="+input+")"
and if the count is zero then there was no transaction
cheers Floh
Subject: RE: ADO Select query problem
Replied by: Cindy Brozyno on 01-02-2012 07:19:38 AM
Thank you, Florian, for your advice. The only way I was able to resolve was by changing the end of my query to UserID = "+input+" or 0 - and adding a default record with 0 as the ID. I do appreciate the assistance.