I am adding data to my database, but would like to retrieve the UnitID that is Auto generated.
using (SqlConnection connect = new SqlConnection(connections))
{
SqlCommand command = new SqlCommand("ContactInfo_Add", connect);
command.Parameters.Add(new SqlParameter("name", name));
command.Parameters.Add(new SqlParameter("address", address));
command.Parameters.Add(new SqlParameter("Product", name));
command.Parameters.Add(new SqlParameter("Quantity", address));
command.Parameters.Add(new SqlParameter("DueDate", city));
connect.Open();
command.ExecuteNonQuery();
}
...
ALTER PROCEDURE [dbo].[Contact_Add]
@name varchar(40),
@address varchar(60),
@Product varchar(40),
@Quantity varchar(5),
@DueDate datetime
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO DBO.PERSON
(Name, Address) VALUES (@name, @address)
INSERT INTO DBO.PRODUCT_DATA
(PersonID, Product, Quantity, DueDate) VALUES (@Product, @Quantity, @DueDate)
END