Professional Documents
Culture Documents
DA0- Data Access Object RDO- Remote Data Object ADO- ActiveX Data Object
Developed By: Ashish Kr Chakrabarty, ARDENT COMPUTECH PVT LTD
Connection Object
Command Object
Data Adapter
name
age
address
phone
DataSet Virtual Database It temporarily stores Data in a disconnected approach for Database Management.
DataSet
Developed By: Ashish Kr Chakrabarty, ARDENT COMPUTECH PVT LTD
// Method use to execute Non-Query(INSERT / UPDATE / DELETE )records public static bool SaveData(string Query) { try { SqlCommand cmd = new SqlCommand(Query, con); con.Open(); cmd.ExecuteNonQuery(); return true; } catch (Exception ex) { return false; } finally { con.Close(); } }
Developed By: Ashish Kr Chakrabarty, ARDENT COMPUTECH PVT LTD
10
// Method use to obtain a single value from the data source public static string FetchScalar(string Query) { SqlCommand cmd = new SqlCommand(Query, con); string s; try { con.Open(); s = Convert.ToString(cmd.ExecuteScalar()); return s; } catch (Exception ex) { return ; } finally { con.Close(); } } } //End of DbAccess class. } //End of the namespace.
Developed By: Ashish Kr Chakrabarty, ARDENT COMPUTECH PVT LTD
11
12
Message:
13
//Event to Add Record in a Table. protected void Button_Add_Click(object sender, EventArgs e) { bool r = DbAccess.SaveData("INSERT INTO <TableName> VALUES ( "+ name.Text + ',"+ age.Text + , +address.Text+ , +phone.Text+ ) "); if (r == true) Message.Text = "Data Successfully Added"; else Message.Text = "Data Can t be Added"; }
14
//Event to Update Record in a Table. protected void Button_Update_Click(object sender, EventArgs e) { bool r = DbAccess.SaveData("UPDATE <TableName> SET Name= " +name.Text + ',Age="+ age.Text + , Address = +address.Text+ WHERE PhoneNo="+phone.Text +" "); if (r) Message.Text = "Data Updated"; else Message.Text = Data Can,t be Updated"; }
Developed By: Ashish Kr Chakrabarty, ARDENT COMPUTECH PVT LTD
15
protected void Button_Delete_Click(object sender, EventArgs e) { bool r = DbAccess.SaveData("DELETE FROM <TableName> WHERE PhoneNo= " + phone.Text + "); if (r) Message.Text = "Data Deleted"; else Message.Text = Data can t be Deleted"; }
16
17
18
Summary
The Disconnected data architecture in ADO.NET is more flexible, efficient than it is in ADO, some of the major issues are ADO.NET being built on XML architecture and its size. DataAdapter is the back bone of implementing the disconnected data architecture XML data can be read into DataSet at the same time Data in the DataSet can be written onto the file in the form of XML Document. DataSet can also be validated against xml schemas
19
20