ADO.Net Components:
Connection, Command, DataReader, DataAdapter
Differentiate between DataSet and RecordSet:
1) DataSet is entire relation DB in memory. Table/Relation/Views While RecordSet is representation of Table. It do not contain information on relationships, Constraints, Keys.
2) DataSet is designed to work in disconnected mode.
3) There’s no concept of cursor-types in a DataSet
4) DataSet has no record pointer.
5) You can store many edits in a DS and write them in Original DataSource in a single call.
6) DataSet internally represents data with XML and can be serialized. Thus you can easily retrieve data from a DB and then write directly to XML file or reverse.
DataSet is always disconnected?
True
What is advantage of DataReader over DataSet?
DataReader is readonly stream of data returned from the DB as the query executes. It contains one row of data at a time and is restricted to forward-only. Supports to a access multiple result sets but only one at a time and in order retrieved. DataReader needs connection to DB throughout its usage. DataReader is faster than DataSet.
Typed DataSet?
Data access is normally done using indexes on collection in object model. In ADO.Net it is possible to create a variation on a Dataset that supports syntax like DataSet.TableName.Rows(0).ColumnName . Errors in syntax are detected during compile time rather than runtime.
Advantages: Data Designer generates typed ds. When we type ds. We get all table names and column names on row. We do not need to remember.
How to reflect updation of data in dataset to database?
Dim ds As New (Typed)DataSet
Dim da As New SqlDataAdapter(“Select Command”)
Dim cd As New SqlCommandBuilder(da)
da.Update(DataTable/DataSet, srcTable)
If SELECT command is SP and to update/insert/delete we have created SPs
We can create SqlCommand Objects in Code and assign it to InsertCommand,
UpdateCommand and DeleteCommand Property of adapter.
What are Different types of command can be executed?
ExecutedNonQuery, ExecuteScaler, ExecuteReader (In Execute NonQuery we can use transaction. In other Scaler and Reader we can not use transaction. We do not need to assign transaction to every command if connection string has ENLIST=true; it automatically assigns current transaction in the Context to the command being executed.
How to Set DataRelation between in two columns:
ds.Relations.Add(DataRelation Object)
New DataRelation(ParentColumns(),childColumns())
New DataRelation("RelationName", ParentColumn, childColumn)
New DataRelation("RelationName", ParentColumn, childColumn, CreateConstraint = True)
New DataRelation("RelationName",ParentColumns(),childColumns(),CreateConstraint=True)
How do we sort the data from a DataTable:
DataTable.Select(strFilter, strSort) As DataRow()
New DataView(DataTable) and DataView.Sort = “Column1,Column2,...)
How do we get only edited/deleted/inserted records from a DataTable:
DataTable.GetChanges(DataRowState.Added Or
DataRowState.Deleted Or
DataRowState.Modified Or
DataRowState.Detached Or
DataRowState.Unchanged)
How does DataAdapter.Fill Work?
Executes the Execute Reader method and gets the reader.
Reads Each ResultSet using NextResultSet of DataReader From the and Fills the DataTable form the reader. Also creates DataTable if MisingSchemaAction is Add/AddWithKey.
Difference between HTML and XML?
XML : User defined tags. Content driven, End tags required , case sensitive. Quotes required around attributes. Slash required in Empty Tags.
What is XSLT and its usage?
XSL Transformations. Used to transform XML document to any other text format such as HTML, text, XML etc.
Connection, Command, DataReader, DataAdapter
Differentiate between DataSet and RecordSet:
1) DataSet is entire relation DB in memory. Table/Relation/Views While RecordSet is representation of Table. It do not contain information on relationships, Constraints, Keys.
2) DataSet is designed to work in disconnected mode.
3) There’s no concept of cursor-types in a DataSet
4) DataSet has no record pointer.
5) You can store many edits in a DS and write them in Original DataSource in a single call.
6) DataSet internally represents data with XML and can be serialized. Thus you can easily retrieve data from a DB and then write directly to XML file or reverse.
DataSet is always disconnected?
True
What is advantage of DataReader over DataSet?
DataReader is readonly stream of data returned from the DB as the query executes. It contains one row of data at a time and is restricted to forward-only. Supports to a access multiple result sets but only one at a time and in order retrieved. DataReader needs connection to DB throughout its usage. DataReader is faster than DataSet.
Typed DataSet?
Data access is normally done using indexes on collection in object model. In ADO.Net it is possible to create a variation on a Dataset that supports syntax like DataSet.TableName.Rows(0).ColumnName . Errors in syntax are detected during compile time rather than runtime.
Advantages: Data Designer generates typed ds. When we type ds. We get all table names and column names on row. We do not need to remember.
How to reflect updation of data in dataset to database?
Dim ds As New (Typed)DataSet
Dim da As New SqlDataAdapter(“Select Command”)
Dim cd As New SqlCommandBuilder(da)
da.Update(DataTable/DataSet, srcTable)
If SELECT command is SP and to update/insert/delete we have created SPs
We can create SqlCommand Objects in Code and assign it to InsertCommand,
UpdateCommand and DeleteCommand Property of adapter.
What are Different types of command can be executed?
ExecutedNonQuery, ExecuteScaler, ExecuteReader (In Execute NonQuery we can use transaction. In other Scaler and Reader we can not use transaction. We do not need to assign transaction to every command if connection string has ENLIST=true; it automatically assigns current transaction in the Context to the command being executed.
How to Set DataRelation between in two columns:
ds.Relations.Add(DataRelation Object)
New DataRelation(ParentColumns(),childColumns())
New DataRelation("RelationName", ParentColumn, childColumn)
New DataRelation("RelationName", ParentColumn, childColumn, CreateConstraint = True)
New DataRelation("RelationName",ParentColumns(),childColumns(),CreateConstraint=True)
How do we sort the data from a DataTable:
DataTable.Select(strFilter, strSort) As DataRow()
New DataView(DataTable) and DataView.Sort = “Column1,Column2,...)
How do we get only edited/deleted/inserted records from a DataTable:
DataTable.GetChanges(DataRowState.Added Or
DataRowState.Deleted Or
DataRowState.Modified Or
DataRowState.Detached Or
DataRowState.Unchanged)
How does DataAdapter.Fill Work?
Executes the Execute Reader method and gets the reader.
Reads Each ResultSet using NextResultSet of DataReader From the and Fills the DataTable form the reader. Also creates DataTable if MisingSchemaAction is Add/AddWithKey.
Difference between HTML and XML?
XML : User defined tags. Content driven, End tags required , case sensitive. Quotes required around attributes. Slash required in Empty Tags.
What is XSLT and its usage?
XSL Transformations. Used to transform XML document to any other text format such as HTML, text, XML etc.
Comments