Answers

Question and Answer:

  Home  ASP.NET 2.0

⟩ How can we implement a Identity (SQL Server) call in an asp.net page?

Try { SqlParameter p0, p1, p2; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spo_sample"; //Param: Return Value p0 = cmd.Parameters.Add("@RowCount", SqlDbType.Int); p0.Direction = ParameterDirection.ReturnValue; p1 = new SqlParameter("@Samplename", SqlDbType.VarChar, 200); p1.Value = Samplename.ToString().Trim(); cmd.Parameters.Add(p1); //Param: Output Identity Value p2 = cmd.Parameters.Add("@Identity", SqlDbType.Int, 0, "SampleID"); p2.Direction = ParameterDirection.Output; conn.Open(); cmd.Connection = conn; int cnt = cmd.ExecuteNonQuery(); int rowCount = (int)cmd.Parameters["@RowCount"].Value; int rowIdentity = p2.Value;}

 140 views

More Questions for you: