This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sql Data Adapter | |
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.SqlDataAdapter_ | |
{ | |
public partial class Form1 : Form | |
{ | |
private string _cString1 = "Data Source=(local);Initial Catalog=avyukta;User Id=sa;Password=iamadmin;"; | |
//SqlCommand cmd; | |
SqlConnection con; | |
SqlDataAdapter adp; | |
DataSet ds; | |
SqlCommandBuilder cb; | |
public Form1() | |
{ | |
InitializeComponent(); | |
con = new SqlConnection(_cString1); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
//DataGrid dg; | |
try | |
{ | |
con.Open(); | |
con.Close(); | |
} | |
catch (Exception) | |
{ | |
} | |
ds = new DataSet(); | |
adp = new SqlDataAdapter("select * from grademstr", con); | |
cb = new SqlCommandBuilder(adp); | |
adp.Fill(ds, "grademstr"); | |
dataGridView1.DataSource = ds; | |
dataGridView1.DataMember = "grademstr"; | |
} | |
private void button2_Click(object sender, EventArgs e) | |
{ | |
cb.GetUpdateCommand(); | |
adp.Update(ds, "grademstr"); | |
} | |
} | |
} |