here i have stored procedure like this
create PROCEDURE [dbo].[InsertDetails]
@Cname varchar (50),
@ImageName varchar (50),
@imagepath varchar(50),
@uploadedby varchar(50)
As
BEGIN
DECLARE @count INT
SET @count = (SELECT COUNT(*) FROM UUDetails)
IF @count >= 20
BEGIN
PRINT 'You cannot insert more than 20 records'
END
ELSE
INSERT INTO UUDetails(UserName,ImageName,ImagePath,UploadedBy,UploadedDate)values(@Cname,@ImageName,@imagepath,@uploadedby,GETDATE() )
RETURN scope_Identity()
END
now i want to display this message in aspx page if total records are 20
try
{
SqlConnection con;
SqlCommand cmd;
SqlParameter ret;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString);
FileUpload1.SaveAs(Server.MapPath("Images/" + filename));
cmd = new SqlCommand("dbo.InsertDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
ret = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
ret.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(ret);
cmd.Parameters.Add("@Cname", SqlDbType.VarChar, 50).Value = txtcustname.Text;
cmd.Parameters.Add("@ImageName", SqlDbType.VarChar, 50).Value = filename;
cmd.Parameters.Add("@Uploadedby", SqlDbType.VarChar, 50).Value = txtuploadedBy.Text;
con.Open();
cmd.ExecuteNonQuery();
int j = Convert.ToInt32(ret.Value);
con.Close();
if (j >= 0)
{
Label1.Text = "<b1>Record sucessfully Inserted</b1>";
gvCustomer.DataBind();
}
}
catch (SqlException ex)
{
Label1.Text =ex.Message;
}
catch(Exception ex)
{
throw ex;
}
how to display an message if records are more than 20
please help me ..