ADO .NET Data Access
In this blog we will discuss how to Access data using ADO .NET and make changes to it.
Coding
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Data.SqlClient;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
UpdatingData
{
public partial
class Form1 :
Form
{
public Form1()
{
InitializeComponent();
}
private void
Form1_Load(object sender,
EventArgs e)
{
SqlConnection conn =
new SqlConnection(
@"Data Source=yourServerName;user id=UserName;password=Password;"
+
"Initial Catalog=DatabaseName");
SqlDataAdapter thisAdapter = new SqlDataAdapter(
"SELECT EMPNO,ENAME FROM EMP", conn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter);
DataSet ds = new DataSet();
thisAdapter.Fill(ds, "Employee");
Console.WriteLine("name
before change: {0}",
ds.Tables["Employee"].Rows[5]["ENAME"]);
ds.Tables["Employee"].Rows[5]["ENAME"] = "Johnson";

Join the conversation! Your thoughts help the community grow.