.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

code not working

Posted By: parthiban     Posted Date: May 01, 2013    Points:5   Category :ASP.Net
here below have a code for restricting booking limit to 10 per day..
but the code not working...


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 = "";



Responses
Author: Dharmendra             
Posted Date: May 02, 2013     Points: 20   

getdate() method gives you complete date mm/dd/yyyy. so datepart (dw, '5/11/7') as dayOfTheWeek,
datename (dw, '5/11/7') as NameOfDay

Author: Anna Harris             
Posted Date: May 14, 2013     Points: 20   

Yes, I agree with Dharmendra as datepart function will give you dayoftheweek, datename and Nameoftheday.

Author: iweballey             
Posted Date: May 17, 2013     Points: 20   

Thanks for your suggestion

Author: Anna Harris             
Posted Date: May 18, 2013     Points: 20   

I am also using option explicit in my code, but didn't know the difference between option explicit and option inter. Can anyone please explain.

Author: Johny Allen             
Posted Date: July 10, 2013     Points: 20   

Thanks for sharing information but given code is not working. some mistake in your code.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend