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

data2

The document is a C# Windows Forms application code that connects to an Access database to retrieve student records. It initializes a connection to the database and reads records from a table named 'studtable' when the form loads. The 'NextRecord' button allows users to navigate through the records, displaying them in text boxes, and shows a message if there are no more records to display.

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)
7 views

data2

The document is a C# Windows Forms application code that connects to an Access database to retrieve student records. It initializes a connection to the database and reads records from a table named 'studtable' when the form loads. The 'NextRecord' button allows users to navigate through the records, displaying them in text boxes, and shows a message if there are no more records to display.

Uploaded by

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

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 Form3 : Form
{
OleDbConnection con = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader dr;
public Form3()
{
InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)


{

con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Administrator\OneDrive\Desktop\DataBase\student.accdb";
con.Open();
cmd.Connection = con;
cmd.CommandText = "select * from studtable";
dr = cmd.ExecuteReader();

private void NextRecord_Click(object sender, EventArgs e)


{
if (dr.Read() == true)
{
textBox1.Text = Convert.ToString(dr[0]);
textBox2.Text = Convert.ToString(dr[1]);
textBox3.Text = dr[2].ToString();
textBox4.Text = dr[3].ToString();
}
else
{
MessageBox.Show("no record");

con.Close();
button1.Enabled = false;
}

}
}
}

You might also like