Based on Output Value - Stop or Continue Stored Procedure Execution<font face=Arial size=2> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3>I have a web page that captures time when the user clicks a series of buttons.<span style="">  </span>There are seven buttons, the user clicks button 1, logs back into the app, then clicks button 2.<span style="">  </span>When the user log back into the app to click button 2, the information specific to button 1 need to be written to the browser; this process continues daily.<span style="">  </span>This is working in classic ASP, now I need to convert it to ASP.NET.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#ff6600" size=3>How do I get one record written for each user as I update information for that record throughout the day?</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#ff6600" size=3>Thank You.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#ff6600" size=3>MsMe.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#808080" size=3><strong><u>Goal:</u></strong></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>1.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>When the user initially logs onto the page their ID, WINT and Time is inserted into the db.</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>2.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>The info in the db is written to the browser each time the user accesses the web page.</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>3.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>The user, throughout the day, clicks each button to capture various times for their activity.</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>4.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>After <span style=""> </span>the initial info is inserted, then all subsequent time stamps needs to be updated based on the record in step one. Such there is only one record of time stamps for each day</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in" align=left><font face=Calibri color="#ff6600" size=3><br></font> </p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3><u>Problem:</u></font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri size=3>My stored proc is entering a new record each time the user logs onto the application.</font></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><font face=Calibri size=3>My code looks like the following:<br></font><span style="font-size:10pt;color:blue;font-family:'Courier New'">ALTER PROCEDURE </span><span style="font-size:10pt;font-family:'Courier New'">dbo.usp_InsertLogin</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'">(</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@UserID <span style="color:blue">char</span>(8),</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@Today <span style="color:blue">datetime</span>,</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@SSNLogon <span style="color:blue">char</span>(15)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">as</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">BEGIN</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span><span style="color:blue">select </span>UserID, Today, SSNLogon <span style="color:blue">FROM </span>Time</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">WHERE </span>(UserID=@UserID <span style="color:blue">and </span>Today=@Today <span style="color:blue">and </span>SSNLogon = @SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">GROUP BY </span>UserID, Today, SSNLogon</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="">            </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">BEGIN</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">INSERT INTO </span><span style="font-size:10pt;font-family:'Courier New'">ATTTblAttendance</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">           </span>(UserID, Today, SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">VALUES </span><span style="font-size:10pt;font-family:'Courier New'">(@UserID,@Today,@SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">END</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">END</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">RETURN<br>_________________________________<br>ALTER PROCEDURE </span><span style="font-size:10pt;font-family:'Courier New'">dbo.usp_GetLogin</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@UserID <span style="color:blue">Char</span>(8),</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@Today <span style="color:blue">DateTime<span style="">   </span></span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">AS</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span><span style="color:blue">SET NOCOUNT ON</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">SELECT </span><span style="font-size:10pt;font-family:'Courier New'">UserID, Today, Login, AMBreakOut, AMBreakIn, LunchOut, LunchIn, </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>PMBreakOut, PMBreakIn, Logout, Comments, LoginLogon, AMBreakOutLogon,<span style="">  </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">    </span><span style="">  </span>AMBreakInLogon, LunchOutLogon, LunchInLogon, PMBreakOutLogon, <span style="">    </span>PMBreakInLogon, LogoutLogon, SSNLogon </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">FROM </span><span style="font-size:10pt;font-family:'Courier New'"><span style="">  </span>Time</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">WHERE </span><span style="font-size:10pt;font-family:'Courier New'">(UserID = @UserID) <span style="color:blue">AND </span>(Today = @Today)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;color:blue;line-height:115%;font-family:'Courier New'">_______________________________</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">Protected</span><span style="font-size:10pt;font-family:'Courier New'"> <span style="color:blue">Sub</span> Page_Load(<span style="color:blue">ByVal</span> sender <span style="color:blue">As</span> <span style="color:blue">Object</span>, <span style="color:blue">ByVal</span> e <span style="color:blue">As</span> System.EventArgs) <span style="color:blue">Handles</span> <span style="color:blue">Me</span>.Load</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span><span style="color:blue">If</span> <span style="color:blue">Not</span> Page.IsPostBack <span style="color:blue">Then</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> dtToday <span style="color:blue">As</span> DateTime</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>dtToday = DateTime.Now.ToLongDateString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>lblDate.Text = dtToday</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> strLogin <span style="color:blue">As</span> <span style="color:blue">String</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style=""> </span>strLogin = Replace(HttpContext.Current.User.Identity.Name.ToString, <span style="color:#a31515">&quot;TIMEDOMAIN\&quot;</span>, <span style="color:#a31515">&quot;&quot;</span>)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">'Establish connection to the database connection</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">   </span><span style="">         </span><span style="color:blue">Dim</span> sqlcon <span style="color:blue">As</span> <span style="color:blue">New</span> SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings(<span style="color:#a31515">&quot;TimeConnectionString&quot;</span>).ToString)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">'Retrives employee's record based on current date</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> ataSelectEmployee <span style="color:blue">As</span> SqlCommand = <span style="color:blue">New</span> SqlCommand</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> ataDataReader <span style="color:blue">As</span> SqlDataReader</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">With</span> ataSelectEmployee</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandType = CommandType.StoredProcedure</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandText = <span style="color:#a31515">&quot;usp_GetLogin&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@UserID&quot;</span>, Session(<span style="color:#a31515">&quot;EmployeeID&quot;</span>))</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@Today&quot;</span>, DateTime.Now.ToShortDateString)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection = sqlcon</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection.Open()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.ExecuteNonQuery()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">End</span> <span style="color:blue">With</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">          </span><span style="">  </span>ataDataReader = ataSelectEmployee.ExecuteReader()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Do</span> <span style="color:blue">While</span> ataDataReader.Read()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLogin.Text = ataDataReader(<span style="color:#a31515">&quot;Login&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblAmBreakOut.Text = ataDataReader(<span style="color:#a31515">&quot;AMBreakOut&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblAMBreakIn.Text = ataDataReader(<span style="color:#a31515">&quot;AMBreakIn&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLunchOut.Text = ataDataReader(<span style="color:#a31515">&quot;LunchOut&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLunchIn.Text = ataDataReader(<span style="color:#a31515">&quot;LunchIn&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblPMBreakOut.Text = ataDataReader(<span style="color:#a31515">&quot;PMBreakOut&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblPMBreakIn.Text = ataDataReader(<span style="color:#a31515">&quot;PMBreakIn&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLogout.Text = ataDataReader(<span style="color:#a31515">&quot;Logout&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Loop</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>ataDataReader.Close()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">'Insert New record</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> cmdAddRecord <span style="color:blue">As</span> SqlCommand = <span style="color:blue">New</span> SqlCommand</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">With</span> cmdAddRecord</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandType = CommandType.StoredProcedure</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandText = <span style="color:#a31515">&quot;usp_InsertLogin&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@UserID&quot;</span>, Session(<span style="color:#a31515">&quot;EmployeeID&quot;</span>))</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@Today&quot;</span>, DateTime.Now.ToShortDateString)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@SSNLogon&quot;</span>, strLogin)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection = sqlcon</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection.Open()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.ExecuteNonQuery()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection.Close()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Dispose()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">End</span> <span style="color:blue">With</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>sqlcon.Close()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span><span style="color:blue">End</span> <span style="color:blue">If</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;line-height:115%;font-family:'Courier New'"><span style="">    </span><span style="color:blue">End</span> <span style="color:blue">Sub</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;color:blue;line-height:115%;font-family:'Courier New'"> </span></p> <p align=left></font> </p> <p align=left> </p> <p align=left> </p>© 2009 Microsoft Corporation. All rights reserved.Fri, 12 Dec 2008 05:35:45 Z91fe0817-6553-4c8d-9f71-d4edf38745d1http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#91fe0817-6553-4c8d-9f71-d4edf38745d1http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#91fe0817-6553-4c8d-9f71-d4edf38745d1MsMehttp://social.msdn.microsoft.com/Profile/en-US/?user=MsMeBased on Output Value - Stop or Continue Stored Procedure Execution<font face=Arial size=2> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3>I have a web page that captures time when the user clicks a series of buttons.<span style="">  </span>There are seven buttons, the user clicks button 1, logs back into the app, then clicks button 2.<span style="">  </span>When the user log back into the app to click button 2, the information specific to button 1 need to be written to the browser; this process continues daily.<span style="">  </span>This is working in classic ASP, now I need to convert it to ASP.NET.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#ff6600" size=3>How do I get one record written for each user as I update information for that record throughout the day?</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#ff6600" size=3>Thank You.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#ff6600" size=3>MsMe.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri color="#808080" size=3><strong><u>Goal:</u></strong></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>1.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>When the user initially logs onto the page their ID, WINT and Time is inserted into the db.</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>2.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>The info in the db is written to the browser each time the user accesses the web page.</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>3.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>The user, throughout the day, clicks each button to capture various times for their activity.</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><font color="#808080"><span style=""><span style=""><font face=Calibri size=3>4.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>After <span style=""> </span>the initial info is inserted, then all subsequent time stamps needs to be updated based on the record in step one. Such there is only one record of time stamps for each day</font></font></p> <p class=MsoListParagraph style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in" align=left><font face=Calibri color="#ff6600" size=3><br></font> </p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3><u>Problem:</u></font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri size=3>My stored proc is entering a new record each time the user logs onto the application.</font></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><font face=Calibri size=3>My code looks like the following:<br></font><span style="font-size:10pt;color:blue;font-family:'Courier New'">ALTER PROCEDURE </span><span style="font-size:10pt;font-family:'Courier New'">dbo.usp_InsertLogin</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'">(</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@UserID <span style="color:blue">char</span>(8),</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@Today <span style="color:blue">datetime</span>,</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@SSNLogon <span style="color:blue">char</span>(15)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">as</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">BEGIN</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span><span style="color:blue">select </span>UserID, Today, SSNLogon <span style="color:blue">FROM </span>Time</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">WHERE </span>(UserID=@UserID <span style="color:blue">and </span>Today=@Today <span style="color:blue">and </span>SSNLogon = @SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">GROUP BY </span>UserID, Today, SSNLogon</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="">            </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">BEGIN</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">INSERT INTO </span><span style="font-size:10pt;font-family:'Courier New'">ATTTblAttendance</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">           </span>(UserID, Today, SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">VALUES </span><span style="font-size:10pt;font-family:'Courier New'">(@UserID,@Today,@SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">END</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">END</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">RETURN<br>_________________________________<br>ALTER PROCEDURE </span><span style="font-size:10pt;font-family:'Courier New'">dbo.usp_GetLogin</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@UserID <span style="color:blue">Char</span>(8),</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>@Today <span style="color:blue">DateTime<span style="">   </span></span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">AS</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span><span style="color:blue">SET NOCOUNT ON</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">SELECT </span><span style="font-size:10pt;font-family:'Courier New'">UserID, Today, Login, AMBreakOut, AMBreakIn, LunchOut, LunchIn, </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">      </span>PMBreakOut, PMBreakIn, Logout, Comments, LoginLogon, AMBreakOutLogon,<span style="">  </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">    </span><span style="">  </span>AMBreakInLogon, LunchOutLogon, LunchInLogon, PMBreakOutLogon, <span style="">    </span>PMBreakInLogon, LogoutLogon, SSNLogon </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">FROM </span><span style="font-size:10pt;font-family:'Courier New'"><span style="">  </span>Time</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">WHERE </span><span style="font-size:10pt;font-family:'Courier New'">(UserID = @UserID) <span style="color:blue">AND </span>(Today = @Today)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;color:blue;line-height:115%;font-family:'Courier New'">_______________________________</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'">Protected</span><span style="font-size:10pt;font-family:'Courier New'"> <span style="color:blue">Sub</span> Page_Load(<span style="color:blue">ByVal</span> sender <span style="color:blue">As</span> <span style="color:blue">Object</span>, <span style="color:blue">ByVal</span> e <span style="color:blue">As</span> System.EventArgs) <span style="color:blue">Handles</span> <span style="color:blue">Me</span>.Load</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span><span style="color:blue">If</span> <span style="color:blue">Not</span> Page.IsPostBack <span style="color:blue">Then</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> dtToday <span style="color:blue">As</span> DateTime</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>dtToday = DateTime.Now.ToLongDateString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>lblDate.Text = dtToday</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> strLogin <span style="color:blue">As</span> <span style="color:blue">String</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style=""> </span>strLogin = Replace(HttpContext.Current.User.Identity.Name.ToString, <span style="color:#a31515">&quot;TIMEDOMAIN\&quot;</span>, <span style="color:#a31515">&quot;&quot;</span>)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">'Establish connection to the database connection</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">   </span><span style="">         </span><span style="color:blue">Dim</span> sqlcon <span style="color:blue">As</span> <span style="color:blue">New</span> SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings(<span style="color:#a31515">&quot;TimeConnectionString&quot;</span>).ToString)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">'Retrives employee's record based on current date</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> ataSelectEmployee <span style="color:blue">As</span> SqlCommand = <span style="color:blue">New</span> SqlCommand</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> ataDataReader <span style="color:blue">As</span> SqlDataReader</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">With</span> ataSelectEmployee</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandType = CommandType.StoredProcedure</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandText = <span style="color:#a31515">&quot;usp_GetLogin&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@UserID&quot;</span>, Session(<span style="color:#a31515">&quot;EmployeeID&quot;</span>))</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@Today&quot;</span>, DateTime.Now.ToShortDateString)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection = sqlcon</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection.Open()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.ExecuteNonQuery()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">End</span> <span style="color:blue">With</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">          </span><span style="">  </span>ataDataReader = ataSelectEmployee.ExecuteReader()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Do</span> <span style="color:blue">While</span> ataDataReader.Read()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLogin.Text = ataDataReader(<span style="color:#a31515">&quot;Login&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblAmBreakOut.Text = ataDataReader(<span style="color:#a31515">&quot;AMBreakOut&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblAMBreakIn.Text = ataDataReader(<span style="color:#a31515">&quot;AMBreakIn&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLunchOut.Text = ataDataReader(<span style="color:#a31515">&quot;LunchOut&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLunchIn.Text = ataDataReader(<span style="color:#a31515">&quot;LunchIn&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblPMBreakOut.Text = ataDataReader(<span style="color:#a31515">&quot;PMBreakOut&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblPMBreakIn.Text = ataDataReader(<span style="color:#a31515">&quot;PMBreakIn&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>lblLogout.Text = ataDataReader(<span style="color:#a31515">&quot;Logout&quot;</span>).ToString</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Loop</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>ataDataReader.Close()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">'Insert New record</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">Dim</span> cmdAddRecord <span style="color:blue">As</span> SqlCommand = <span style="color:blue">New</span> SqlCommand</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">With</span> cmdAddRecord</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandType = CommandType.StoredProcedure</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.CommandText = <span style="color:#a31515">&quot;usp_InsertLogin&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@UserID&quot;</span>, Session(<span style="color:#a31515">&quot;EmployeeID&quot;</span>))</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@Today&quot;</span>, DateTime.Now.ToShortDateString)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Parameters.AddWithValue(<span style="color:#a31515">&quot;@SSNLogon&quot;</span>, strLogin)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection = sqlcon</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection.Open()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.ExecuteNonQuery()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Connection.Close()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>.Dispose()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">End</span> <span style="color:blue">With</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>sqlcon.Close()</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span><span style="color:blue">End</span> <span style="color:blue">If</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;line-height:115%;font-family:'Courier New'"><span style="">    </span><span style="color:blue">End</span> <span style="color:blue">Sub</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;color:blue;line-height:115%;font-family:'Courier New'"> </span></p> <p align=left></font> </p> <p align=left> </p> <p align=left> </p>Tue, 18 Nov 2008 19:34:46 Z2008-11-19T13:49:39Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#b0fac4c0-b720-4377-8e09-0bd8e3e9ee02http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#b0fac4c0-b720-4377-8e09-0bd8e3e9ee02Jens K. Suessmeyer -http://social.msdn.microsoft.com/Profile/en-US/?user=Jens%20K.%20Suessmeyer%20-Based on Output Value - Stop or Continue Stored Procedure Execution<p> </p> <p align=left>Is this not working or do you just need a review for that ?</p> <p align=left> </p> <p align=left> </p> <p align=left>Jens K. Suessmeyer</p> <p align=left><font face=Arial size=2></font> </p>Tue, 18 Nov 2008 20:17:56 Z2008-11-18T20:17:56Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#983a1318-9895-479a-a30f-df915a432107http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#983a1318-9895-479a-a30f-df915a432107BeforeAndAfter1974http://social.msdn.microsoft.com/Profile/en-US/?user=BeforeAndAfter1974Based on Output Value - Stop or Continue Stored Procedure Execution<p>I don't understand the issue.</p> <p align=left> </p> <p align=left>What is the expected result? What is the real result?</p> <p align=left> </p> <p align=left>A.D.T.</p> <p align=left><font face=Arial size=2></font> </p>Tue, 18 Nov 2008 20:35:03 Z2008-11-18T20:35:03Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#b23063c6-9126-4f0e-af3c-72702bd2a074http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#b23063c6-9126-4f0e-af3c-72702bd2a074MsMehttp://social.msdn.microsoft.com/Profile/en-US/?user=MsMeBased on Output Value - Stop or Continue Stored Procedure Execution<font face=Arial size=2> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3><u>Problem:</u></font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri size=3>My stored proc is entering a new record each time the user logs onto the application; instead of only one record.  I have not been able to not have the Insert Stored Proc not to insert an additonal records when the user logs onto the page subsequent times.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri size=3></font> </p> <p class=MsoNormal style="margin:0in 0in 10pt" align=left><font face=Calibri size=3>MsMe.</font></p></font>Wed, 19 Nov 2008 01:30:21 Z2008-11-19T01:30:21Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#abbeced9-dc3c-4615-b5c0-e49f25ad03c8http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#abbeced9-dc3c-4615-b5c0-e49f25ad03c8Jens K. Suessmeyer -http://social.msdn.microsoft.com/Profile/en-US/?user=Jens%20K.%20Suessmeyer%20-Based on Output Value - Stop or Continue Stored Procedure Execution<p align=left><font face=Arial size=2>That is not a problem of the stored procedure. Your application logic will have to determine if is has to log the user in the database again. A common approach for this is to write an information in the Session Context and to check this upon request, if not filled log the user if filled go ahead and skip the logging. </font></p> <p align=left> </p> <p align=left>Jens K. Suessmeyer</p>Wed, 19 Nov 2008 09:12:17 Z2008-11-19T09:12:17Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#a44f5599-2dee-482d-9489-9ec5a02285f2http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#a44f5599-2dee-482d-9489-9ec5a02285f2BeforeAndAfter1974http://social.msdn.microsoft.com/Profile/en-US/?user=BeforeAndAfter1974Based on Output Value - Stop or Continue Stored Procedure Execution<p align=left><font face=Arial size=2>You 'could' add logic to the stored procedure to check to see if a record already exists but you'd have to decide on a constraint. Do you only want 1 record per day?</font></p> <p align=left> </p> <p align=left>If NOT EXISTS(SELECT * FROM myTable WHERE myTimeStamp &gt; DATEADD(day, -1, GETDATE()))</p> <p align=left>--Do your insert here</p> <p align=left> </p> <p align=left>A.D.T.</p>Wed, 19 Nov 2008 13:26:00 Z2008-11-19T13:49:39Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#4ae68aee-5ed1-491a-9e68-37af7eca9e2bhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#4ae68aee-5ed1-491a-9e68-37af7eca9e2bMsMehttp://social.msdn.microsoft.com/Profile/en-US/?user=MsMeBased on Output Value - Stop or Continue Stored Procedure Execution<p>Hello A.D.T.,</p> <p align=left>Thank you for your direction I modified my stored procedure to reflect the values that I knew would be passed into it and after days and days of going around in circles, it W O R K E D!!  *If Not Exists* did it, only one record per day per person, my updates which are associated with various buttons work.</p> <p align=left> </p> <p align=left>Thank you very much.</p> <p align=left>I am walking on <img src="http://forums.microsoft.com/msdn/WebResource.axd?d=NySzF1eivP_rMoc50GQJzcvS4MHMOEKwYrCIgDtzuzlw7GsNki3H_INlfYaLgkxF5RV2Vtsa_jEdXQDthcNnQg2&amp;t=633337194230757564">.</p> <p align=left> </p> <p align=left>MsMe.</p> <p align=left><font face=Arial size=2></font> </p>Wed, 19 Nov 2008 13:53:19 Z2008-11-19T13:53:19Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#d9bb4373-0a0e-4d6d-b2c2-5ad5516410cfhttp://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/91fe0817-6553-4c8d-9f71-d4edf38745d1#d9bb4373-0a0e-4d6d-b2c2-5ad5516410cfBeforeAndAfter1974http://social.msdn.microsoft.com/Profile/en-US/?user=BeforeAndAfter1974Based on Output Value - Stop or Continue Stored Procedure Execution<p>Hi MsMe,</p> <p align=left> </p> <p align=left>I thought that's what you were trying to do with the initial SELECT but wasn't sure.</p> <p align=left> </p> <p align=left>However, Jens makes a good point. While the stored procedure check does work, it not very efficient to keep calling a stored procedure in your page only to disqualify every execution after the first. You should later on revisit this design and create a front-end validation to only call the stored procedure on the first login attempt.</p> <p align=left> </p> <p align=left>Edit: ...or more accurately, I would add an UPDATE to the Else of your IF statement above to update the Time to reflect a last login attempt. This is pretty standard.</p> <p align=left> </p> <p align=left>So you would have:</p> <p align=left> </p> <p align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">ALTER PROCEDURE </span><span style="font-size:10pt;font-family:'Courier New'">dbo.usp_InsertLogin</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'">(</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>      </span>@UserID <span style="color:blue">char</span>(8),</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>      </span>@Today <span style="color:blue">datetime</span>,</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>      </span>@SSNLogon <span style="color:blue">char</span>(15)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>      </span>)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">as</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>If NOT EXISTS(</span><span style="color:blue">select </span>UserID, Today, SSNLogon <span style="color:blue">FROM </span>Time</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>            </span><span style="color:blue">WHERE </span>(UserID=@UserID <span style="color:blue">and</span><span style="color:blue"> </span>SSNLogon = @SSNLogon</span></p> <blockquote dir=ltr style="margin-right:0px"> <blockquote dir=ltr style="margin-right:0px"> <blockquote dir=ltr style="margin-right:0px"> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'">AND Today &gt; DATEADD(day, -1, GETDATE()))</span></p></blockquote></blockquote></blockquote> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>            </span><span>            </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">BEGIN</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">INSERT INTO </span><span style="font-size:10pt;font-family:'Courier New'">ATTTblAttendance</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;font-family:'Courier New'"><span>           </span>(UserID, Today, SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">VALUES </span><span style="font-size:10pt;font-family:'Courier New'">(@UserID,@Today,@SSNLogon)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">END</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"></span> </p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"></span> </p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">ELSE</span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">UPDATE <font color="#000000">Time</font></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"><font color="#000000">SET Today = GETDATE()</font></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"><font color="#000000">WHERE UserID=@UserID <span style="color:blue">and </span>SSNLogon = @SSNLogon</font></span></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'">RETURN</span></p> <p align=left> </p></div></div> <p align=left> </p></span> <p></p> <p class=MsoNormal style="margin:0in 0in 0pt;line-height:normal" align=left><span style="font-size:10pt;color:blue;font-family:'Courier New'"></span></p> <p align=left> </p> <p align=left>Good luck,</p> <p align=left> </p> <p align=left>A.D.T.</p> <p align=left><font face=Arial size=2></font> </p>Wed, 19 Nov 2008 16:43:59 Z2008-11-19T16:43:59Z