I have an ASP.NET C # application and in a WebForm I must insert data in a table. For this, create a stored procedure and you can insert null data:
CREATE PROCEDURE [Insertar_Tabla] @var1 INT=NULL, @var2 VARCHAR(10)=NULL, @var3 DATETIME=NULL AS BEGIN SET NOCOUNT ON; INSERT INTO tabla(var1,var2,var3) VALUES(@var1,@var2,@var3) SELECT SCOPE_IDENTITY(); END
And from the code .cs I call this Procedure. And by means of input parameters the values of var.
Is it better not to declare the parameters and that the Procedure is responsible for making them NULL if it corresponds or better to pass the variables as a NULL value ?, example:
@var1 = 0; @var2=""; @var3=new DateTime();
For practical purposes and good programming practices, since the current system, although small, is scalable and possibly modified.