how to solve this error

Posted by Parthibansk under ASP.NET on 5/2/2013 | Points: 10 | Views : 645 | Status : [Member] | Replies : 1
here below have a code for restricting booking limit to 10 per day..
but the code not working...

RECORDS NOT INSERTING

SqlConnection con = new SqlConnection("Data Source=parthi\\sqlexpress;Integrated Security=true;Initial Catalog=employee");

con.Open();
SqlCommand cmd = new SqlCommand("select count(id) from joinees where year(regdate) = year(getdate()) and month(regdate) = month(getdate()) and day(regdate) = day(getdate())", con);
int intcount = Convert.ToInt32(cmd.ExecuteNonQuery());

if (intcount>10)
{
string sqlstr;
sqlstr = "INSERT INTO joinees([name], [email],[phoneno]) values ('" + txtName.Text.ToString() + "','" + txtEMAIL.Text.ToString() + "','" + txtPHONE.Text.ToString() + " ')";



con.Close();
Label1.Text = " Thank You For Booking";
Label1.ForeColor = System.Drawing.Color.Green;
}
else
{


Label1.ForeColor = System.Drawing.Color.Red;
Label1.Text = "BOOKINGS FILLED FOR THE DAY.. TRY TOMMORROW";

}

Label1.Visible = false;
txtName.Text = "";
txtEMAIL.Text = "";
txtPHONE.Text = "";

TABLE STRUCTURE:

ID NAME EMAIL PHONENO REGDATE




Responses

Posted by: Santhi on: 5/2/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

What value you are getting in intcount ?

if (intcount>10)

You have used greater than symbol here.. so, do you want to allow the users to book only if the count value is greater than 10??????

Thanks & Regards,
Santhi .V

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response