Create Stored Procedure
Posted by: VICTOR GONZALEZ
Date: August 13, 2020 12:58PM

hello,

Anyone have any idea how to create a stored procedure with c# or vb.net?

My code is as follows, but it shows a syntax error and from workbench it runs without errors.


*****************************************************
String query = "USE `databasename`;";
query += " DROP procedure IF EXISTS `sp_create`;";
query += " DELIMITER $$";
query += " CREATE DEFINER=`user`@`%` PROCEDURE `sp_create` (";
query += " in vId int(11), in vfName varchar(150)";
query += " )";
query += " BEGIN";
query += " INSERT INTO Contacts (Id, fName)";
query += " VALUES (vId, vfName);";
query += " SELECT LAST_INSERT_ID() AS IdRegistro;";
query += " END$$";

ExecuteCommand(query);


private static void ExecuteCommand(string queryString,
string connectionString)
{
using (SqlConnection connection = new SqlConnection(
connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}

**********************************


thanks,

Options: ReplyQuote


Subject
Written By
Posted
Create Stored Procedure
August 13, 2020 12:58PM
August 13, 2020 01:26PM
August 13, 2020 02:32PM
August 15, 2020 10:11AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.