Salve a tutti, ho questa stored procedure
ALTER PROCEDURE [dbo].[newsInsert]
@titolo nvarchar(200),
@testo text,
@image bit = 0
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO news (titolo, testo, image) VALUES (@titolo, @testo, @image)
RETURN @@IDENTITY
END
Ed effettivamente da sql server management mi ritorna l'id autoincrementante
Da Asp.net ho
protected void Page_Load(object sender, EventArgs e)
{
}
protected void buttSubmit_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(configuration.DbConnectionString);
SqlCommand s1 = new SqlCommand("newsInsert", conn);
s1.CommandType = System.Data.CommandType.StoredProcedure;
s1.CommandText = "newsInsert";
s1.Parameters.Add("@titolo", titolo);
s1.Parameters.Add("@testo", testo);
s1.Parameters.Add("@image", fu.HasFile);
conn.Open();
int res = (int)s1.ExecuteScalar();
conn.Close();
La stored procedure viene eseguita, perche' nella tabella compaiono i dati inseriti, ma il valore ritornato e' sempre null... qualcuno ha qualche idea?
Grazie