Skip to main content

To develop simple window Application with database "School.mdb" and "student" table in the school.mdb database,student table with Roll no, Name and Address Field


//We will change name to s_name 

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 _2012
{
    public partial class Form1 : Form
    {
     //   OleDbCommand cmd;
        OleDbConnection con;
      //  OleDbDataReader dr;
        OleDbDataAdapter da;
        OleDbCommandBuilder builder;
        DataSet ds;
        string query = "";
        int max = 0,min=0;
        public Form1()
        {
            InitializeComponent();
            con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\anuj vb 10\2012\school.mdb");
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "roll no";
            label2.Text = "name";
            label3.Text = "address";
            button1.Text = "load";
            button2.Text = "previous";
            button3.Text = "next";
            button4.Text = "exit";

        }

        private void button4_Click(object sender, EventArgs e)
        {
            MessageBox.Show("exitting from the application");
            Application.Exit();
        }
        private void fill()
        {
       

            textBox1.Text=ds.Tables[0].Rows[min]["roll_no"].ToString();
            textBox2.Text = ds.Tables[0].Rows[min]["s_name"].ToString();
            textBox3.Text = ds.Tables[0].Rows[min]["address"].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
            query = "select * from student";
                    da = new OleDbDataAdapter(query, con);
            builder =new OleDbCommandBuilder(da);
            ds=new DataSet();
            da.Fill(ds,"student");
           max= ds.Tables[0].Rows.Count;
           if (ds.Tables.Count > 0)
           {
               MessageBox.Show("the table is empty");
               return;
           }
            fill();
         
            con.Close();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            min -= 1;
            if (min == -1)
                min = max - 1;
            fill();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            min += 1;
                if(min==max)
                    min=0;
            fill();
        }
    }
}

Comments

Popular posts from this blog

PROGRAM TO PRINT COLOURS OF RAINBOW ACCORDING TO THE NO. INPUTTED BY THE USER

#include,stdio.h> #include<conio.h> void main() { int ch; printf("INPUT A NUMBER\n"); scanf("%d",&ch); switch(ch) { case 6: printf("Red"); break; case 5 : printf(" Orange"); break; case 4 : printf(" Yellow"); break; case 3 : printf(" Green"); break; case 2 : printf(" Blue"); break; case 1 : printf(" Indigo"); break; case 0 : printf(" Violet"); break; default : ("wrong input "); } } SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLE TEMPERATURE CONVERSION COMMISSION OF A SALESMAN PRINT NUMBERS IN DESCENDING ORDER BIGGEST NUMBER AMONG THREE NUMBERS CALCULATE DIVISION A YEAR IS LEAP OR NOT A NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5 PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTERED DATA STRUCTURES ENTER DETAILS OF A STUDENT ENTER DETAILS OF A ST...

unix commands

 

Baby doge paws

Baby doge paws link 🎉 Join the BabyDoge PAWS Clicker adventure! Solve challenges, join daily events, and invite friends. Stay tuned for the token airdrop! 🐾 🌟 Earn 10k PAWS as a welcome bonus 🌟 Get 25k PAWS with Telegram Premium https://t.me/BabyDogePAWS_Bot?start=r_6394860582