hi
this is Estate_info table in database:
id |
Code |
1 |
10 |
2 |
11 |
3 |
12 |
4 |
13 |
5 |
14 |
and I put lable in page that will bind Code from table in lable below are codes:
SP:
alter procedure [dbo].[ViewCode]
as
begin
select(select Top 1 code+1
from Estate_info
order by date desc) as code
end
private void Viewcode()
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand("ViewCode", conn))
{
conn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
while (_dr.Read())
{
Lblcode.Text = _dr["code"].ToString();
}
}
}
}
now according table it will dispaly:
Lblcode.text==> 15 (Top 1 code+1)...
now here I want if I delete rows from Estate_info Like below:
id |
code |
1 |
10 |
3 |
12 |
4 |
13 |
5 |
14 |
here I delete row with id=2 so code:11 isn't in table...
now I want at first check table if all number(codes number) be in table after that it does :(select(select Top 1 code+1
from Estate_info
order by date desc) as code
if like above table number wasn't in table it will dispaly that number
i.e:
here I want lblcode display--> 11 (becuse number 11 isn't in table)
how I can do it?
best regards
neda