User cannot submit daily report twice in a day?? RRS feed

  • Question

  • hello all,

                 Actually  when user submit report in a day,user  again  submit  report in the  same day.. but i want user cannot submit the report twice in the same day ?? please help me..

    my code is:

                               SqlCommand comm = new SqlCommand("SELECT * FROM REPORT WHERE username='" + Label2.Text + "' and date=(SELECT Today=convert(varchar, GETDATE(), 101)) ", con);
                SqlDataReader dr = comm.ExecuteReader();
                if (dr.HasRows)
                    Aaleert.Show("You can't submit the report twice in a day..............................");

                    SqlCommand cmd = new SqlCommand("INSERT INTO REPORT(username,report,date) SELECT '" + Label2.Text + "','" + TextBox1.Text + "',GETDATE()", con);

    Monday, July 16, 2012 6:06 AM


  • Your SQL statement will return a string date value in the format MM/DD/YYYY (e.g. 07/16/2012). Is this the format of the date in your Label?

    It's usually recommend that date values be compared in their native numeric format rather than as string/text values.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Tony xiao Wednesday, July 25, 2012 10:47 AM
    • Unmarked as answer by Tony xiao Wednesday, July 25, 2012 10:49 AM
    • Marked as answer by Allen_MSDN Friday, August 10, 2012 3:27 AM
    Monday, July 16, 2012 12:19 PM