private int AddRecordCategory()
{
AdminAllCategory aAdminAllCategory = new AdminAllCategory();
AdminAllCategoryBLL allCategoryBLL = new AdminAllCategoryBLL();
int Action = 0;
try
{
if (CategoryID > 0)
{
aAdminAllCategory.CategoryId = Convert.ToInt32(CategoryIdtxt.Text);
}
else
{
//CategoryGateway objCategoryGateway = new CategoryGateway();
string columnName = "CategoryID";
string tableName = "Deal.Category";
aAdminAllCategory.CategoryId = allCategoryBLL.MaxId(columnName, tableName) + 1;
}
aAdminAllCategory.Category = BanglaCategory.Text;
aAdminAllCategory.CategoryEng = EnglishCategory.Text;
aAdminAllCategory.IsActive = Convert.ToInt32(IsActive.Text);
aAdminAllCategory.IsHit = Convert.ToInt32(HitDropDown.Text);
aAdminAllCategory.OrderBy = Convert.ToInt32(OrderBy.Text);
if (Hit.Text != "")
{
aAdminAllCategory.hit = Convert.ToInt32(Hit.Text);
}
else
{
aAdminAllCategory.hit = 0;
}
aAdminAllCategory.MetaKeyword = metaKeyWord.InnerText;
aAdminAllCategory.MetaDescription = MetaDescription.InnerText;
aAdminAllCategory.VisibleInDevice = Convert.ToInt32(IsVisible.SelectedValue);
aAdminAllCategory.AppColorCode = AppColorCode.Text;
aAdminAllCategory.CategoryTitleBng = BngPageTitle.Text;
aAdminAllCategory.CategoryTitleEng = EngPageTitle.Text;
Action = allCategoryBLL.InsertCategory(aAdminAllCategory);
}
catch (Exception ex)
{
lblSystemMessage.Text = "Warning!!Contact With IT";
}
return Action;
}
在这里,我想将这些属性保存在数据库中,但希望在保存这些列之前查看是否将CategoryTitleEng
和CategoryTitleBng
属性保存在数据库中。然后,这将显示如下消息:
这些属性已经存在。
网关和存储过程如下所示.....
public int AddRecord_Category(AdminAllCategory aAdminAllCategory)
{
int intActionResult = 0;
int isActive = 1;
//int isDeleted = 0;
try
{
OpenConnection();
ArrayList arlSqlParameters = new ArrayList();
arlSqlParameters.Add(new SqlParameter("@CategoryID", aAdminAllCategory.CategoryId));
arlSqlParameters.Add(new SqlParameter("@Category", aAdminAllCategory.Category));
arlSqlParameters.Add(new SqlParameter("@IsHit", aAdminAllCategory.IsHit));
arlSqlParameters.Add(new SqlParameter("@IsActive", aAdminAllCategory.IsActive));
arlSqlParameters.Add(new SqlParameter("@OrderBy", aAdminAllCategory.OrderBy));
arlSqlParameters.Add(new SqlParameter("@CategoryEng", aAdminAllCategory.CategoryEng));
arlSqlParameters.Add(new SqlParameter("@MetaKeyword", aAdminAllCategory.MetaKeyword));
arlSqlParameters.Add(new SqlParameter("@MetaDescription", aAdminAllCategory.MetaDescription));
arlSqlParameters.Add(new SqlParameter("@VisibleInDevice", aAdminAllCategory.VisibleInDevice));
arlSqlParameters.Add(new SqlParameter("@AppColorCode", aAdminAllCategory.AppColorCode));
arlSqlParameters.Add(new SqlParameter("@CategoryTitleEng",aAdminAllCategory.CategoryTitleEng));
arlSqlParameters.Add(new SqlParameter("@CategoryTitleBng", aAdminAllCategory.CategoryTitleBng));
intActionResult = this.ExecuteActionQuery("Deal.USP_AddDealsCategory", arlSqlParameters);
}
catch (Exception ex)
{
}
finally
{
CloseConnection();
}
return intActionResult;
}
CREATE PROCEDURE [Deal].[USP_AddDealsCategory]
(
@CategoryID int,
@Category nvarchar(150),
@IsActive int,
@IsHit int,
@OrderBy int,
@CategoryEng varchar(150),
@MetaKeyword varchar(500),
@MetaDescription varchar(500),
@VisibleInDevice int = 0,
@AppColorCode varchar(50) = '',
@CategoryTitleEng varchar(200),
@CategoryTitleBng nvarchar(200),
@MetaKeywordBng nvarchar(200),
@MetaDescriptionBng nvarchar(200)
)
AS
BEGIN
Insert into Deal.Category
(CategoryID,Category,IsActive,IsHit,OrderBy,Hit,CategoryEng,MetaKeyword,MetaDescription,VisibleInDevice,AppColorCode,CategoryTitleEng,CategoryTitleBng,MetaKeywordBng,MetaDescriptionBng)
Values(@CategoryID,@Category,@IsActive,@IsHit,@OrderBy,0,@CategoryEng,@MetaKeyword,@MetaDescription,@VisibleInDevice,@AppColorCode,@CategoryTitleEng,@CategoryTitleBng,@MetaKeywordBng,@MetaDescriptionBng)
END
答案 0 :(得分:0)
您已将属性@CategoryTitleBng两次添加到参数列表中。这就是为什么它会给出错误 这应该只是一次
arlSqlParameters.Add(new SqlParameter("@CategoryTitleBng", aAdminAllCategory.CategoryTitleBng));