Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
example of insert delete update value in access database in C# window application
Posted
Comments
R. Giskard Reventlov 16-Feb-12 14:54pm    
Poorly phrased question. What do you actually want to know? What have you tried?

Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]

Hope this link to help you

AND more in google search for ADO.net
 
Share this answer
 
v2
Hi,
FOR SHOW database:

//******************************FOR SHOW database:************************
OleDbConnection con1 = new OleDbConnection();
con1.ConnectionString = "provider = microsoft.ace.oledb.12.0;data source = C:\\University.accdb";
con1.Open();


//create the database query
OleDbDataAdapter da = new OleDbDataAdapter("select * from Student", con1);
// data Table : a table for our data
DataTable dt = new DataTable();
da.Fill(dt);

dataGridView1.DataSource = dt.DefaultView;
con1.Close();
////******************************FOR Insert into database:************************
// connect to data base
OleDbConnection con1 = new OleDbConnection();
con1.ConnectionString = "provider = microsoft.ace.oledb.12.0;data source = C:\\University.accdb";

OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"insert into Student (StuNO, Name,Family,Field,Age)VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')";

/// this :(StuNO, Name,Family,Field,Age) name of fields in "Student" table
///
///
cmd.Connection = con1;
con1.Open();
cmd.ExecuteNonQuery();
System.Windows.Forms.MessageBox.Show("Recrod Succefully Created");
con1.Close();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";

// you should click agin on the show button to see inserted record.
 
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