Hi! I used below cod;, but I couldn't get Id:
create procedure GetIdGost
@Name varchar(25),
@IdGost int output
as
declare @id int,@d int,@i int
select @id = max(Id) from TblFirst
select @d = max(Id) from TblSecond
if isnull(@id,0) = 0 and isnull(@d,0) = 0
begin
set @i = 1
select @i
end
else if (isnull(@id,0) > isnull(@d,0))
set @i = @id + 1
else if (isnull(@id,0) < isnull(@d,0))
set @i = @d + 1
begin
set nocount on;
insert into TblPeople(Id, Name)values(@i, @Name)
set @IdGost = scope_identity()
return @IdGost
end
protected void AddGost_Click(object sender, EventArgs e)
{
addgost(Name.Text);
}
public bool addgost(string name)
{
SqlConnection con = new SqlConnection(UserData);
SqlCommand cmd = con.CreateCommand();
string sql = "exec GetIdGost '" + name.ToString() + "'";
cmd.CommandText = sql;
con.Open();
try
{
cmd.BeginExecuteNonQuery();
IdText.Text = cmd.Parameters["@Idg"].Value.ToString();
}
catch { }
con.Close();
return true;
}