I have created procedure for ItemUpdate.
Key_Name is a primary key.
begin tran
Create proc ItemUpdate(@Key_Name varchar(50),@Number bigint,@TimeStamp date)
as
begin
if exists (select * from OPISEQNUM with (updlock) where KEY_NAME = 'ID1')
update OPISEQNUM set NUMBER = NUMBER+1
where KEY_NAME = 'ID1'
else
insert OPISEQNUM (KEY_NAME, NUMBER,timestamp)
values ('ID1', 0,getdate())
end
commit tran
using c#
int number;
DateTime timestamp = DateTime.Now;
public string GenerateSeqNum(string key_Name)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlTransaction transaction = con.BeginTransaction();
string opiorderid = "";
try
{
c ...
Go to the complete details ...