Click here to Skip to main content
15,887,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to code asp.net(website) with c# and mysql insert,update,delete ...
Posted
Updated 22-Feb-12 23:11pm
v2

 
Share this answer
 
Comments
abey e mathews 23-Feb-12 5:12am    
but i need for web application,i need only basic code to insert,update,delete..
(not using stored procedure)
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{


MySqlConnection myConnection = new MySqlConnection("Database=test;Data Source=localhost;User Id=sa;Password=admin");
string myInsertQuery = "INSERT INTO orders (id, name) Values(1,'test')";
MySqlCommand myCommand = new MySqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();

}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900