Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 24th, 2005, 09:20 AM
Authorized User
 
Join Date: Oct 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Preventing "Back", and duplicate responses

I have a working app that reads in a studentsID and the class that they recently finished. The app simply is an evaluation of the class. After they hit submit I take them to a different webpage. I do not want to allow them to go back to the previous (evaluation) page and resubmit. I also want to prevent that same student/class combo from being entered into the system.

I would appreciate any help on this subject.

Thanks

 
Old October 24th, 2005, 11:38 AM
Authorized User
 
Join Date: Oct 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I have the logic to make it work. My problem is that the if statement is NEVER returning a null even when it should. Is my syntax wrong?

void Page_Load(object sender, EventArgs e) {

    if (!Page.IsPostBack) {


       string HeldKey = Request.QueryString["HeldKey"];
       string StudentID = Request.QueryString["StudentID"];
       Set_Name = Request.QueryString["Set_Name"];

       string SelectTest = "SELECT Smile_results.student_ID, smile_results.Held_Key FROM smile_results WHERE (smile_results.Student_ID = '"+StudentID+"' and smile_results.Held_Key = '"+HeldKey+"')";


         if (SelectTest == null)
            {
              SqlConnection myConnection = new SqlConnection(ConnectionString);
              SqlDataAdapter myCommand = new SqlDataAdapter(SelectCommand, myConnevtion);

              DataSet ds = new DataSet();
              myCommand.Fill(ds);

              DataGrid2.DataSource = ds;
              DataGrid2.DataBind();
                            }
           else Response.Redirect("http://elearning.diebold.com/testb/Sorry.htm");

                         }



 
Old October 25th, 2005, 07:53 AM
Authorized User
 
Join Date: Oct 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured out that I was comparing the wrong things. You can't compare the strings you have to compare the dataAdapters. Unfortunatly I'm still getting thame results.
Here is my new code. I am comparing myTestcom and myTestcom2. Any ideas why they aren't being seen as equal by the if statement?

string SelectTest = "SELECT Smile_results.student_ID, smile_results.Held_Key FROM smile_results WHERE ((smile_results.Student_ID = '"+StudentID+"') and (smile_results.Held_Key = '"+HeldKey+"'))";

string SelectTest2 = "SELECT Smile_results.student_ID, smile_results.Held_Key FROM smile_results WHERE ((smile_results.Student_ID = null) and (smile_results.Held_Key = null))";

SqlConnection myConnection2 = new SqlConnection(ConnectionString);
SqlDataAdapter myCommand2 = new SqlDataAdapter(SelectCommand, myConnection2);
SqlDataAdapter myTestcom = new SqlDataAdapter(SelectTest, myConnection2);
SqlDataAdapter myTestcom2 = new SqlDataAdapter(SelectTest2, myConnection2);

if (myTestcom==myTestcom2)
 {

    DataSet ds = new DataSet();
    myCommand2.Fill(ds);

    DataGrid2.DataSource = ds;
    DataGrid2.DataBind();
 }







Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing Hotlinking simtrade Classic ASP Professional 0 October 14th, 2005 05:06 PM
Preventing Data Loss when hitting back button IronStar Javascript How-To 8 July 23rd, 2005 07:00 PM
Preventing new instances of the same application aehb C# 3 May 18th, 2005 01:14 PM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM
Preventing Page Caching neeter HTML Code Clinic 3 June 5th, 2003 01:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.