//Sql Data Reader 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.Sql; using System.Data.SqlClient; namespace killercodes_in.SqlDataReader1 { public partial class Form1 : Form { private string _cString1 = "Data Source=(local);Initial Catalog=avyukta;User Id=sa;Password=iamadmin;"; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { SqlConnection sqc = new SqlConnection(_cString1); SqlCommand cmd = new SqlCommand("select * from grademstr", sqc); SqlDataReader reader; try { sqc.Open(); sqc.Close(); } catch { } sqc.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { textBox1.Text = reader["Gradeid"].ToString(); textBox2.Text = reader["GradeCode"].ToString(); textBox3.Text = reader["GradeDesc"].ToString(); textBox4.Text = reader["DA_Percent"].ToString(); } reader.Close(); cmd.Dispose(); sqc.Close(); } } }