Program in C# for creating a connection with Ms access and storing data in Access.
https://smileandcode.blogspot.com/2020/01/simple-python-program-in-jupyter.html
1. Create a Windows form like this.
Here we have create a database with name MCA4th and table with student name.
4. Now for creating a connection with database you need to add using System.Data.OleDb; in form.
5.Now you need to create a connection object.
Code is this:
public partial class Form1 : Form
{private OleDbConnection connection= new OleDbConnection();
public Form1()
{
InitializeComponent();
}
OUTPUT:-
https://smileandcode.blogspot.com/2020/01/simple-python-program-in-jupyter.html
1. Create a Windows form like this.
2. Now go on new and create a new database in Ms Access.
3. After creating database create a new table in it.
4. Now for creating a connection with database you need to add using System.Data.OleDb; in form.
5.Now you need to create a connection object.
Code is this:
public partial class Form1 : Form
{private OleDbConnection connection= new OleDbConnection();
public Form1()
{
InitializeComponent();
}
6. Now write this code on button.
private void button1_Click(object sender, EventArgs e)
{
connection.ConnectionString=@"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Documents and Settings\admin\My Documents\mca4th.accdb";
connection.Open();
OleDbCommand command= new OleDbCommand();
command.Connection=connection;
command.CommandText = "Insert into student (Name,Age,Class)values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "') ";
command.ExecuteNonQuery();
MessageBox.Show("Submitted");
}
OUTPUT:-
thanks for the help
ReplyDeletecode is really working
ReplyDeletethanks forthe connection program of .net and access
ReplyDelete