Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Retrieve Stored Data From Datagridview

gridview grid datagridview

  • Please log in to reply
No replies to this topic

#1 percis


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 09 July 2012 - 12:12 AM

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 DatabaseConnection
   public partial class frmDataConnection : Form
	  OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source= c:\users\student\documents\visual studio 2010\Projects\DatabaseConnection\DatabaseConnection\Database2.accdb");
	  public frmDataConnection()
	  private void Form1_Load(object sender, EventArgs e)

	  private void button3_Click(object sender, EventArgs e) //Exit button
	  private void button1_Click(object sender, EventArgs e) //Save
		 string vsql = String.Format(" insert into student_details values ({0},'{1}',{2},'{3}')", int.Parse(txtStudentNumber.Text), txtStudentName.Text, int.Parse(txtAge.Text), txtAddress.Text);
		 OleDbCommand vcom = new OleDbCommand(vsql, vcon);
		 MessageBox.Show("Data stored successfully");
	  private void button4_Click(object sender, EventArgs e) //Showall button
		 string vsql = "select * from student_details";
		 OleDbCommand vcom = new OleDbCommand(vsql, vcon);
		 DataSet vds = new DataSet();
		 OleDbDataAdapter vda = new OleDbDataAdapter(vcom);
		 vda.Fill(vds, "res");
		 dataGridView1.DataSource = vds.Tables["res"];
	  private void button2_Click(object sender, EventArgs e) //Clear button
		 txtStudentNumber.Text = "";
		 txtStudentName.Text = "";
		 txtAge.Text = "";
		 txtAddress.Text = "";
	  private void textBox1_TextChanged(object sender, EventArgs e)// to enter a students' name
	  private void button1_Click_1(object sender, EventArgs e)
		 // retrieve button to get a
		 //students'no,age,address by typing the name which in the grid view
	  private void display_TextChanged(object sender, EventArgs e)// to display a students no., age,address


how to write codings for the above-mentioned prgm to retrieve data ( e.g.age, address)from the data grid specifically by a persons' name?
  • 0

Also tagged with one or more of these keywords: gridview, grid, datagridview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download