Code Implementation of ADO.Net Using Disconnected Architecture in Windows Form

Опубликовано: 16 Апрель 2026
на канале: Touch Star Institute
889
11

How to implement ADO.Net Using Disconnected Architecture in windows form application along with datagridview.
#Code
#ADD
DataRow newrow = ds.Tables["Students"].NewRow();

newrow["std_name"] = textBox1.Text;
newrow["fathername"] = textBox2.Text;
newrow["Dob"] = dateTimePicker1.Value;
newrow["contactNo"] = textBox3.Text;
newrow["std_email"] = textBox4.Text;

ds.Tables["Students"].Rows.Add(newrow);
builder = new SqlCommandBuilder(dataadater);
dataadater.Update(ds, "Students");
loaddatafromDB();
#Edit
DataGridViewRow dr = dataGridView1.CurrentRow;
DataColumn[] dtcol = new DataColumn[1];
dtcol[0] = ds.Tables["Students"].Columns["StdID"];
ds.Tables["Students"].PrimaryKey = dtcol;
DataRow updaterow = ds.Tables["Students"].Rows.Find(Convert.ToInt32(dr.Cells[0].Value));

updaterow["std_name"] = textBox1.Text;
updaterow["fathername"] = textBox2.Text;
updaterow["Dob"] = (DateTime)dateTimePicker1.Value;
updaterow["contactNo"] = textBox3.Text;
updaterow["std_email"] = textBox4.Text;
builder = new SqlCommandBuilder(dataadater);
dataadater.Update(ds, "Students");
loaddatafromDB();

#Delete
DataGridViewRow dr = dataGridView1.CurrentRow;
DataColumn[] dtcol = new DataColumn[1];
dtcol[0] = ds.Tables["Students"].Columns["StdID"];
ds.Tables["Students"].PrimaryKey = dtcol;
DataRow deleterow = ds.Tables["Students"].Rows.Find(Convert.ToInt32(dr.Cells[0].Value));
deleterow.Delete();
builder = new SqlCommandBuilder(dataadater);
dataadater.Update(ds, "Students");
loaddatafromDB();