Calling MySQL SP's with In & Out Params in VB .Net
Mysql stored proc is
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `Check1`(
IN P_Name VARCHAR(50)
,OUT P_Id INT
)
BEGIN开发者_开发百科
INSERT INTO Company
(Name, Expiry, CreatedDate, Active)
VALUES
(P_Name, 90, NOW(), 1);
SET P_Id = @@identity;
END
Company TABLE has
- CompanyID
- Name
- CreateDate
- Active
as various columns
I need use VB .Net to call this procedure, insert value into the database and get the ID (primary key - company ID).
Whenever I insert a row, I need to retrieve the ID. Right now, I am able only to insert the row, but don't know how to call a SP with both input and output parameters from VB.
Check out the Direction member of OleDbParameter.
精彩评论