Hi i have the routine below. when called from vb.net i get CustomerID cannot be null. issue with iNewCId.
if a replace iNewCId with a number it works.
Please help
Thanks
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `rModifyCustomer`(
IN CId INT,
IN CRef VARCHAR(45),
IN CName VARCHAR(45),
IN GendId INT,
IN TitId INT,
IN FName VARCHAR(30),
IN SName VARCHAR(30),
IN Init CHAR(2),
IN DateOB DATE
)
BEGIN
DECLARE iNewCId INT;
SELECT iNewCId = MAX(CustomerId) + 1 FROM
tblCustomer;
IF CId = -1 THEN
INSERT INTO tblCustomer
(
CustomerId,
CustomerRef,
CustomerName,
GenderId,
TitleId,
FirstName,
Surname,
Initial,
DOB
)
VALUES
(
iNewCId,
CRef,
CName,
GendId,
TitId,
FName,
SName,
Init,
DateOB
);
ELSE
UPDATE
tblCustomer
SET
CustomerRef = CRef,
CustomerName = CName,
GenderId = GendId,
TitleId = TitId,
FirstName = FName,
Surname= SName,
Initial = Init,
DOB = DateOB
WHERE CustomerId = CId;
END IF;
END
if a replace iNewCId with a number it works.
Please help
Thanks
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `rModifyCustomer`(
IN CId INT,
IN CRef VARCHAR(45),
IN CName VARCHAR(45),
IN GendId INT,
IN TitId INT,
IN FName VARCHAR(30),
IN SName VARCHAR(30),
IN Init CHAR(2),
IN DateOB DATE
)
BEGIN
DECLARE iNewCId INT;
SELECT iNewCId = MAX(CustomerId) + 1 FROM
tblCustomer;
IF CId = -1 THEN
INSERT INTO tblCustomer
(
CustomerId,
CustomerRef,
CustomerName,
GenderId,
TitleId,
FirstName,
Surname,
Initial,
DOB
)
VALUES
(
iNewCId,
CRef,
CName,
GendId,
TitId,
FName,
SName,
Init,
DateOB
);
ELSE
UPDATE
tblCustomer
SET
CustomerRef = CRef,
CustomerName = CName,
GenderId = GendId,
TitleId = TitId,
FirstName = FName,
Surname= SName,
Initial = Init,
DOB = DateOB
WHERE CustomerId = CId;
END IF;
END