0% found this document useful (0 votes)
3 views

data1

The document is a C# Windows Forms application code for managing student records in a database. It includes functionalities to insert, delete, and update student information using an OleDbConnection to connect to an Access database. The application provides a user interface with text boxes and a combo box for inputting student data.

Uploaded by

alazarjesus4
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

data1

The document is a C# Windows Forms application code for managing student records in a database. It includes functionalities to insert, delete, and update student information using an OleDbConnection to connect to an Access database. The application provides a user interface with text boxes and a combo box for inputting student data.

Uploaded by

alazarjesus4
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace MDIsec1
{
public partial class Form2 : Form
{
OleDbConnection con = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)


{
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Administrator\OneDrive\Desktop\DataBase\student.accdb";
}

private void insert_Click(object sender, EventArgs e)


{
con.Open();

cmd.Connection = con;
cmd.CommandText = "Insert into studtable values('" + textBox1.Text +
"','" + textBox2.Text + "','" + textBox3.Text + "','" + comboBox1.Text + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("one record add");
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
comboBox1.Text = "";

con.Close();
}

private void delet_Click(object sender, EventArgs e)


{
con.Open();
cmd.Connection=con;
cmd.CommandText="Delete from studtable where id='" + textBox1.Text +
"'";
cmd.ExecuteNonQuery();
MessageBox.Show("one delete");

con.Close();

private void update_Click(object sender, EventArgs e)


{
con.Open();
cmd.Connection = con;

cmd.CommandText="update studtable set sex='"+comboBox1.Text+"' where id


='"+textBox1.Text+"'";
cmd.ExecuteNonQuery();
MessageBox.Show("one record Update");

con.Close();
}
}
}

You might also like