Hi.
I have designed a webform wiht asp.net4 which is for Employees.in one of my page there is Checkbox and also a Textbox.so if the user checked that checkbox ,it means he has decided (to show i have studied inside the organization), and also in the Database i have mada it boolian (0,1), in otherwise if he didn't check the Checkbox the Textbox to be available for him and can write inside , and also some Nvarchar(he has studied some where else) will be inserted in the database.
a part of the code is in below:
switch (IsAlmostafaCheckBox.Checked)
{
case true:
command.Parameters.AddWithValue("@IsInOrganization", this.IsOrganizationCheckBox.Checked);
command.Parameters.AddWithValue("@InstituteName", DBNull.Value);
break;
case false:
command.Parameters.AddWithValue("@InstituteName", this.InstituteNameTextBox.Text);
command.Parameters.AddWithValue("@IsInOrganization", this.IsOrganizationCheckBox.Checked);
break;
}
but the problem is that when i press the button an error occures and says
that you have omitted the IsInOrganization parameter in your Stored Procedure , and can not accept the null value in the database
so because i didn't want to make the field Nullable, i tried to change the stored procedure , like this :
ALTER PROCEDURE [dbo].[Insert_GeneralPassedTerms_SP](
@CityId int,
@IsInOrganization bit,
@TermTitle nvarchar(1000),
@InstituteName nvarchar(500),
@Date Datetime ,
@Duration decimal(4,1),
@Score decimal(4,2),
@Description nvarchar(1000)
)
AS
begin
if @InstituteName=null
begin
insert into GeneralPassedTerms(
CityId,
IsInOrganization,
TermTitle,
InstituteName,
Date,
Duration,
Score,
Description
)
Values(
@CityId,
@IsInOrganization,
@TermTitle,
'Null',
@Date,
@Duration,
@Score,
@Description
)
End
else
Insert into GeneralPassedTerms(
CityId,
IsInOrganization,
TermTitle,
InstituteName,
Date,
Duration,
Score,
Description
)
Values(
@CityId,
@IsInOrganization,
@TermTitle,
@InstituteName,
@Date,
@Duration,
@Score,
@Description
)
select @@IDENTITY
end
I don't whether this procedure is correct or not ? would you please help me?