I would like to know how I can obtain a data from the stored procedure in sql server and then insert it into a variable type int
in c #.
Already I wrote a code that has to return me the ID
greater than I have in my table, but the code that I wrote receives in response "1"
This is my stored procedure:
create procedure NumId
AS
BEGIN
SELECT MAX(id) AS id FROM dbo.ProductsData
END
go
execute numID
This is code in c #:
string spq = "NumId";
SqlCommand cmd = new SqlCommand(spq, con);
cmd.CommandType = CommandType.StoredProcedure;
tblData[5, i].Value = Convert.ToInt32(cmd.ExecuteScalar());