Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1447

Create Stored Procedure (3 replies)

$
0
0
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,

Viewing all articles
Browse latest Browse all 1447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>