Create Stored Procedure
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,
Subject
Written By
Posted
Create Stored Procedure
August 13, 2020 12:58PM
Sorry, you can't reply to this topic. It has been closed.
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.