in order to save data from access database and search from i
in order to save data from access database and search from it in c# windows application form. i created two buttons Save and Search . what codes should i write behind each of them to make them work property.
note: it OLEDb connection
Solution
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.SqlClient;
 
 SqlConnection conn;
 SqlCommand comm;
 SqlDataReader dreader;
private void btnsave_Click(object sender, EventArgs e)
         {
             conn = new SqlConnection(connstring);
             conn.Open();
             comm = new SqlCommand(\"insert into student_detail values(\" + txtrn.Text + \",\'\" + txtname.Text + \"\',\" + txtage.Text + \",\'\" + txtcourse.Text + \"\')\", conn);
             try
             {
                 comm.ExecuteNonQuery();
                 MessageBox.Show(\"Saved...\");
             }
             catch (Exception)
             {
                 MessageBox.Show(\"Not Saved\");
             }
             finally
             {
                 conn.Close();
             }
         }
 private void btnsearch_Click(object sender, EventArgs e)
         {
             conn = new SqlConnection(connstring);
             conn.Open();
             comm = new SqlCommand(\"select * from student_detail where roll_no = \" + txtrn.Text + \" \", conn);
            try
             {
                 dreader = comm.ExecuteReader();
                 if (dreader.Read())
                 {
                     txtname.Text = dreader[1].ToString();
                     txtage.Text = dreader[2].ToString();
                     txtcourse.Text = dreader[3].ToString();
                 }
                 else
                 {
                     MessageBox.Show(\" No Record\");
                 }
                 dreader.Close();
             }
             catch (Exception)
             {
                 MessageBox.Show(\" No Record\");
             }
             finally
             {
                 conn.Close();
             }
         }


