J'ai un problème avec la base de données. Le Proc stocké doit être appelé avec 3 ou 4 paramètres. Si ImageID n'est pas donné, alors il doit entrer dans la boucle If et s'exécuter. Si ImageID est donné, exécutez la partie else du proc stocké. Mais je ne sais pas pourquoi est que montrer procédure ou la fonction « » attend le paramètre « @ImageID », qui n'a pas été fourni. »Procédure ou fonction "" attend le paramètre '', qui n'a pas été fourni
Merci à l'avance
if (!hasImage)
{
parameters = new SqlParameter[]
{
new SqlParameter("@LocationID", LocationID),
new SqlParameter("@PrimaryID",
Convert.ToInt32(CategoryList[i].ToString().Split(',')[0])),
new SqlParameter("@SecondaryID",
Convert.ToInt32(CategoryList[i].ToString().Split(',')[1]))
};
SqlHelper.ExecuteNonQuery(
DbConnString,
System.Data.CommandType.StoredProcedure,
"TempUpdateMerchantCategories_Insert",
parameters);
}
else
{
parameters = new SqlParameter[]
{
new SqlParameter("@LocationID", LocationID),
new SqlParameter("@PrimaryID",
Convert.ToInt32(CategoryList[i].ToString().Split(',')[0])),
new SqlParameter("@SecondaryID",
Convert.ToInt32(CategoryList[i].ToString().Split(',')[1])),
new SqlParameter("@ImageID",
Convert.ToInt64(ImageData[j].ToString().Split(',')[0]))
};
SqlHelper.ExecuteNonQuery(
DbConnString,
System.Data.CommandType.StoredProcedure,
"TempUpdateMerchantCategories_Insert",
parameters);
}
Le Proc stocké est comme ça.
CREATE PROCEDURE [dbo].[TempUpdateMerchantCategories_Insert]
(
@LocationID BIGINT,
@PrimaryID INT,
@SecondaryID INT,
@ImageID BIGINT)
AS
BEGIN
if (@ImageID is null)
BEGIN
SET NOCOUNT ON;
INSERT INTO TempMerchant_Location_Category(
LocationID,
PrimaryID,
SecondaryID)
VALUES (
@LocationID,
@PrimaryID,
@SecondaryID)
END
ELSE
BEGIN
SET NOCOUNT ON;
INSERT INTO TempMerchant_Location_Category(
LocationID,
PrimaryID,
SecondaryID,
ImageID)
VALUES(
@LocationID,
@PrimaryID,
@SecondaryID,
@ImageID)
END
END
Incroyable !! Plus d'une réponse Merci a tous! – Ram