records inserting after 10
Java
public DataSet GetEmployees()
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=EmpDB;User ID=sa;Password=sa");
con.Open();
SqlCommand cmd = new SqlCommand("Select count(ID) from carbookingdetails where createdon=Getdate()", con);
intCount= cmd.ExecuteScalar()
if (intCount>10)
alert("Booking is over for today");
else
{
//do Insertion Process in carbookdetails table.
}
Suthish NairRank #92 · 22.8K reputationPosted Apr 17, 2013, 5:43 AM EDT
Run above query in SQL Server Management Studio and check the count.
Also try converting to int ..
int.Parse(cmd.ExecuteScalar().ToString()); or (int)cmd.ExecuteScalar();
Riddhi ValechaRank #794 · 2.9K reputationPosted Apr 17, 2013, 10:05 PM EDT
int count = convert.toint32(cmd.executescalar());
if(count>0)
{
alert("");
}
else
{
// Insertion.
}
------------
Hope this helps. If yes, do mark the answer as accepted. Please ignore the spelling mistakes.
parthiban karnanRank #2,548 · 548 reputationPosted Apr 18, 2013, 12:24 AM EDT
executed the below code for restricting daily user registrants to 10..data not inserting..
protected void btnSave_Click(object sender, EventArgs e)
bhuvana santhi16 reputationPosted Apr 18, 2013, 1:05 AM EDT
parthiban karnanRank #2,548 · 548 reputationPosted Apr 18, 2013, 1:25 AM EDT
Select count(ID) from JOINEES where REGDATE=Getdate()
not getting count value
bhuvana santhi16 reputationPosted Apr 18, 2013, 1:29 AM EDT
parthiban karnanRank #2,548 · 548 reputationPosted Apr 18, 2013, 1:35 AM EDT
Select count(id) from JOINEES where year(id)= year(getdate()) and month(id) = month(getdate()) and day(id)=day(getdate())
bhuvana santhi16 reputationPosted Apr 18, 2013, 1:39 AM EDT
select count(id) fromdailybookings
where year(date) = year(getdate())
and month(date) = month(getdate())
and day(date) = day(getdate())
bhuvana santhi16 reputationPosted Apr 18, 2013, 2:02 AM EDT
parthiban karnanRank #2,548 · 548 reputationPosted Apr 18, 2013, 2:06 AM EDT
bhuvana santhi16 reputationPosted Apr 18, 2013, 3:18 AM EDT
what value you are getting in the intcount variable after executing the query?
Riddhi ValechaRank #794 · 2.9K reputationPosted Apr 18, 2013, 3:54 AM EDT
What count are you looking for??
If its total number of rows, user count(*).
Eg - select count(*) from tablename;
Ravikumar G178 reputationPosted Apr 24, 2013, 2:13 AM EDT