My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Wednesday, 2 January 2019
How to use SQL Store procedure in C# || How to Get Latest Record Id afte...
create proc sP_insertadmin
(
@ad_id int out,
@ad_name nvarchar(50),
@ad_password nvarchar(50)
)
as
begin
insert into tbl_Admin values(@ad_name,@ad_password);
select @ad_id=SCOPE_IDENTITY();
end
-------------------------------------------------------------------------------------------------
public string Addwithstoreproc(Admin ad)
{
string msg = null;
SqlConnection conn = new SqlConnection(connectionstring);
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("sP_insertadmin", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ad_name", SqlDbType.NVarChar, 50).Value = ad.name;
cmd.Parameters.Add("@ad_password", SqlDbType.NVarChar, 50).Value = ad.password;
SqlParameter para = new SqlParameter();
para.SqlDbType = SqlDbType.Int;
para.Direction = ParameterDirection.Output;
para.ParameterName = "@ad_id";
cmd.Parameters.Add(para);
cmd.ExecuteNonQuery();
msg = para.Value.ToString();
}
catch (Exception)
{
msg = "Data couldnot inserted...........";
}
return msg;
}
---------------------------------------------------------------------------
Subscribe to:
Posts (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Load event: pictureBox3.Image = Image .FromFile( @"C:\Users\salman\Documents\Visual Studio 2013\Projects\WindowsFormsApplication3\W...