I Using Mysql Database and Stored Procedure to insert data in databse. Here my Id was Auto increment in .
how to insert data using Stored procedure in Web api core.
I Using Mysql Database and Stored Procedure to insert data in databse. Here my Id was Auto increment in .
how to insert data using Stored procedure in Web api core.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Nov 3, 2022, 1:46 AM EDT
using MySql.Data.MySqlClient;string cs = @"server=localhost;userid=dbuser;password=s$cret;database=mydb"; public void InsertData(Employee emp) {using(MySqlConnection con= new MySqlConnection("cs")) {MySqlCommand cmd= new MySqlCommand("spInsert",con); cmd.Parameters.AddWithValue("@name",emp.Name); cmd.Parameters.AddWithValue("@salary",emp.salary);con.Open();cmd.ExecuteNonQuery(); }}public class Employee { public int Id{get;set;} public string Name {get;set;} public int salary {get;set;}}/// Stored procedure mysql> DELIMITER // ; mysql> Create PROCEDURE insert_studentinfo( IN @name varchar(20),IN @salary int)-> BEGIN-> insert into Employee(name, salary) values (@name, @salary);-> END //Jignesh KumarRank #91 · 22.9K reputationPosted Nov 3, 2022, 7:36 AM EDT
Hi Raj,
Please refer this one,
https://www.c-sharpcorner.com/article/crud-operations-in-asp-net-core-web-api-using-ado-net/
https://www.c-sharpcorner.com/UploadFile/e562e5/crud-operation-using-web-api-2-and-stored-procedure-with-a-s/
Jaydeep PatilRank #205 · 11.7K reputationPosted Nov 5, 2022, 1:29 AM EDT
You can check my following article for the CRUD Operation in .NET Core 6 using Stored Procedure
https://www.c-sharpcorner.com/article/crud-operation-using-entity-framework-core-and-stored-procedure-in-net-core-6-w/