Can you give a overview of ADO.NET architecture ?What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What is the use of command objects and what are the methods provided by the commandobject ?
What is the use of dataadapter ?What are basic methods of Dataadapter ?What is Dataset object?
What are the various objects in Dataset ?How can we connect to Microsoft Access , Foxpro , Oracle etc ?
How do we connect to SQL SERVER , which namespace do we use ?How do we use stored procedure in ADO.NET and how do we provide parameters tothe stored procedures?How can we force the connection object to close after my datareader is closed ?I want to force the datareader to return only schema of the datastore rather than data ?How can we fine tune the command object when we are expecting a single row or a singlevalue ?Which is the best place to store connectionstring in .NET projects ?What are steps involved to fill a dataset ?How can we use dataadapter to fill a dataset ?What are the various methods provided by the dataset object to generate XML?How can we save all data from dataset ?How can we check that some changes have been made to dataset since it was loaded ?How can we cancel all changes done in dataset ? , How do we get values which are changed in a dataset ?How can we add/remove row’s in “DataTable” object of “DataSet” ?What’s basic use of “DataView” ?What’s difference between “DataSet” and “DataReader” ?Why is DataSet slower than DataReader ?How can we load multiple tables in a DataSet ?How can we add relation’s between table in a DataSet ?What’s the use of CommandBuilder ?What’s difference between “Optimistic” and “Pessimistic” locking ?How many way’s are there to implement locking in ADO.NET ?How can we perform transactions in .NET?What’s difference between Dataset. clone and Dataset. copy ?Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?Explain in detail the fundamental of connection pooling?What is Maximum Pool Size in ADO.NET Connection String?How to enable and disable connection pooling?
window.google_render_ad();
If we want to connect to many databases in dataaccess layer such as MSAccess,Sql server,oracle means not to a particular database depends on condition we have to connect to appropriate database in this scenario if we without changing code Ho wdo you handle this situation?
and use this Key name where it is needed
If you need SqlServer DataBase
using System.Data.SqlClient;
in DataAcess Layer
public SqlConnection Connection()
{
try
{
con = new SqlConnection
(ConfigurationManager.AppSettings
["SqlServerDatabase"].ToString().Trim());
return con;
}
catch (Exception exp)
{
throw exp;
}
}
What is @@rowcount and with small code snippet explain the usage?
@@ROWCOUNT:Returns the number of rows affected by the last statement.ex:UPDATE authors SET au_lname = 'Jones'WHERE au_id = '999-888-7777'IF @@ROWCOUNT = 0print 'Warning: No rows were updated'.
What provider ADO.net use by default?
The below link gives the answer for this question. ADO.NET does not default to anything.http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic43724.aspx
sqlclient.
can we execute trigger normally at the desired time?
No.no we can't execute triggers explicitly.they gets executed automatically when we perform DML operations
A trigger is a DB object like proc. or func. stored in data
dictonary. It will fire implicitly with event on which it
written.
Main use of a trigger are
-- we can take backup of data.
-- Can be used for auditing purpose.
-- For applying complex bussiness rule.
Etc.
Differnce between Stored procedure and user defined functions?
what is sql Injection?
SQl Injection is used by hacker or professional to damage
the data through intellectaul technique. For example, in
this text box , If I write SQL statement in such a way that
effect its database. example " hi, 'delete * from emp;'
This is what We say to inject in Sql by writing DML in
textbox.
SQL Injection is he process of passing SQL code into an
application in a way that was not intended by the
application developer or it is a strategy for attacking
databases.
Example
An ASP page asks the user for a name and a password.
SELECT FROM users WHERE username="whatever" AND
password="mypassword".
It seems safe,but it is not. A user might enter somthing
like this 'OR 1>0....
when this is plugged into the SQL statewments the result
looks like this:
SELECT FROM users WHERE username="OR 1>0 " AND
password=" ";
This injectin comments out of the password portion of the
statement. It results in a list of all the names in the
users table. So any user could get into your system.
When a haker gives input like username = vinod@gmail.com andpassword = a' or 'x' = 'x-- than user name will be acceptedand password x=x will always true so system can allow tohaker to login.
Sql Injection is one of the input manipulation attacks, which in case the sql statement is directly buildup from an string concatanation, in which the user can change through entry the result sql statement.For Example:select top 1 username from users where username = '&txtusername.Text&'. If the user enters the text with ' or -- he can add more command to the outcoming sql statement and change the query set.
odp.net is Oracle database provider for .net for high
performence data base access to the oracle from any .net
language. It provides data access facility to the any .net
language
Feature of DataSet:1.DataSet provide disconnected mode.2.We can Use DataRelation between Table in DataSet.3.DataSet Contain Hug of Data from database.4.DataSet can Load a From Other Resource Like XmlFile.DisAdvantage of DataSet1.DataSet is slower in compare to RecordSet Because at First Data Convert in xml before providing the user.2.we can not use freuqent changes data in dataset because it works as disconnected mode.
what is a dataview?why is it used for?
A DataView provides a dynamic view of data whose content, ordering, and membership reflect changes to the underlying DataTable as they occur.
If i am expecting a single result from sqlserverdatabase then what command should i follow ?sqlcommand.executereader (commandbehaviour.singleresult)or sqlcommand.executescalar()?
sqlcommand.executescalar()
How you will set the datarelation between two columns?
ADO.NET provides DataRelation object to set relation between two columns.It helps to enforce the following constraints,a unique constraint, which guarantees that a column in the table contains no duplicates and a foreign-key constraint,which can be used to maintain referential integrity.A unique constraint is implemented either by simply setting the Unique property of a data column to true, or by adding an instance of the UniqueConstraint class to the DataRelation object's ParentKeyConstraint.As part of the foreign-key constraint, you can specify referential integrity rules that are applied at three points,when a parent record is updated,when a parent record is deleted and when a change is accepted or rejected.
Explain the ADO . Net Architecture ?
ADO.Net is the data access model for .Net ?based applications. It can be used to access relational database systems such as SQL SERVER 2000, Oracle, and many other data sources for which there is an OLD DB or ODBC provider.To a certain extent, ADO.NET represents the latest evolution of ADO technology. However, ADO.NET introduces some major changes and innovations that are aimed at the loosely coupled and inherently disconnected ? nature of web applications.A .Net Framework data provider is used to connecting to a database, executing commands, and retrieving results. Those results are either processed directly, or placed in an ADO.NET DataSet in order to be exposed to the user in an ad-hoc manner, combined with data from multiple sources, or remoted between tiers. The .NET Framework data provider is designed to be lightweight, creating a minimal layer between the data source and your code, increasing performance without sacrificing functionality.Following are the 4 core objects of .Net Framework Data provider:Connection: Establishes a connection to a specific data source .Command: Executes a command against a data source. Exposes Parameters and can execute within the scope of a Transaction from a Connection. DataReader: Reads a forward-only, read-only stream of data from a data source. DataAdapter: Populates a DataSet and resolves updates with the data source.The .NET Framework includes the .NET Framework Data Provider for SQL Server (for Microsoft SQL Server version 7.0 or later), the .NET Framework Data Provider for OLE DB, and the .NET Framework Data Provider for ODBC.The .NET Framework Data Provider for SQL Server: The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. It is lightweight and performs well because it is optimized to access a SQL Server directly without adding an OLE DB or Open Database Connectivity (ODBC) layer. The following illustration contrasts the .NET Framework Data Provider for SQL Server with the .NET Framework Data Provider for OLE DB. The .NET Framework Data Provider for OLE DB communicates to an OLE DB data source through both the OLE DB Service component, which provides connection pooling and transaction services, and the OLE DB Provider for the data source .The .NET Framework Data Provider for OLE DB: The .NET Framework Data Provider for OLE DB uses native OLE DB through COM interoperability to enable data access. The .NET Framework Data Provider for OLE DB supports both local and distributed transactions. For distributed transactions, the .NET Framework Data Provider for OLE DB, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services.The .NET Framework Data Provider for ODBC: The .NET Framework Data Provider for ODBC uses native ODBC Driver Manager (DM) through COM interoperability to enable data access. The ODBC data provider supports both local and distributed transactions. For distributed transactions, the ODBC data provider, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services.The .NET Framework Data Provider for Oracle: The .NET Framework Data Provider for Oracle enables data access to Oracle data sources through Oracle client connectivity software. The data provider supports Oracle client software version 8.1.7 and later. The data provider supports both local and distributed transactions (the data provider automatically enlists in existing distributed transactions, but does not currently support the EnlistDistributedTransaction method).The .NET Framework Data Provider for Oracle requires that Oracle client software (version 8.1.7 or later) be installed on the system before you can use it to connect to an Oracle data source..NET Framework Data Provider for Oracle classes are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You will need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider.Choosing a .NET Framework Data Provider.NET Framework Data Provider for SQL Server: Recommended for middle-tier applications using Microsoft SQL Server 7.0 or later. Recommended for single-tier applications using Microsoft Data Engine (MSDE) or Microsoft SQL Server 7.0 or later.Recommended over use of the OLE DB Provider for SQL Server (SQLOLEDB) with the .NET Framework Data Provider for OLE DB. For Microsoft SQL Server version 6.5 and earlier, you must use the OLE DB Provider for SQL Server with the .NET Framework Data Provider for OLE DB..NET Framework Data Provider for OLE DB: Recommended for middle-tier applications using Microsoft SQL Server 6.5 or earlier, or any OLE DB provider. For Microsoft SQL Server 7.0 or later, the .NET Framework Data Provider for SQL Server is recommended. Recommended for single-tier applications using Microsoft Access databases. Use of a Microsoft Access database for a middle-tier application is not recommended..NET Framework Data Provider for ODBC: Recommended for middle-tier applications using ODBC data sources. Recommended for single-tier applications using ODBC data sources..NET Framework Data Provider for Oracle: Recommended for middle-tier applications using Oracle data sources. Recommended for single-tier applications using Oracle data sources. Supports Oracle client software version 8.1.7 and later. The .NET Framework Data Provider for Oracle classes are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider.
Whate are different types of Commands available with DataAdapter ?
The SqlDataAdapter has SelectCommand, InsertCommand,
DeleteCommand and UpdateCommand.
What are the different row versions available?
Current:The current values for the row. This row version does not exist for rows with a RowState of Deleted.Default :The row the default version for the current DataRowState. For a DataRowState value of Added, Modified or Current, the default version is Current. For a DataRowState of Deleted, the version is Original. For a DataRowState value of Detached, the version is Proposed.Original:The row contains its original values.Proposed:The proposed values for the row. This row version exists during an edit operation on a row, or for a row that is not part of a DataRowCollection.
http://msdn2.microsoft.com/en-us/library/ww3k31w0.aspx
Which are the different IsolationLevels ?
Serialized : Data read by a current transaction cannot be
changed by another transaction until the current
transaction finishes. No new data can be inserted that
would affect the current transaction. This is the safest
isolation level and is the default.
Repeatable : Read Data read by a current transaction
cannot be changed by another transaction until the current
transaction finishes. Any type of new data can be inserted
during a transaction.
Read Committed : A transaction cannot read data that is
being modified by another transaction that has not
committed. This is the default isolation level in
Microsoft? SQL Server.
Read Uncommitted : A transaction can read any data, even
if it is being modified by another transaction. This is the
least safe isolation level but allows the highest
concurrency.
Any Any isolation level is supported. This setting is
most commonly used by downstream components to avoid
conflicts. This setting is useful because any downstream
component must be configured with an isolation level that
is equal to or less than the isolation level of its
immediate upstream component.
Therefore, a downstream component that has its isolation
level configured as Any always uses the same isolation
level that its immediate upstream component uses. If the
root object in a transaction has its isolation level
configured to Any, its isolation level becomes Serialized.
http://msdn2.microsoft.com/en-us/library/aa213034.aspx
Explain what a diffgram is and its usage ?
A DiffGram is an XML format that is used to identify
current and original versions of data elements. The DataSet
uses the DiffGram format to load and persist its contents,
and to serialize its contents for transport across a
network connection. When a DataSet is written as a
DiffGram, it populates the DiffGram with all the necessary
information to accurately recreate the contents, though not
the schema, of the DataSet, including column values from
both the Original and Current row versions, row error
information, and row order.
When sending and retrieving a DataSet from an XML Web
service, the DiffGram format is implicitly used.
Additionally, when loading the contents of a DataSet from
XML using the ReadXml method, or when writing the contents
of a DataSet in XML using the WriteXml method, you can
select that the contents be read or written as a DiffGram.
The DiffGram format is divided into three sections: the
current data, the original (or "before") data, and an
errors section, as shown in the following example.
The DiffGram format consists of the following blocks of
data:
The name of this element, DataInstance, is used for
explanation purposes in this documentation. A DataInstance
element represents a DataSet or a row of a DataTable.
Instead of DataInstance, the element would contain the name
of the DataSet or DataTable. This block of the DiffGram
format contains the current data, whether it has been
modified or not. An element, or row, that has been modified
is identified with the diffgr:hasChanges annotation.
This block of the DiffGram format contains the original
version of a row. Elements in this block are matched to
elements in the DataInstance block using the diffgr:id
annotation.
This block of the DiffGram format contains error
information for a particular row in the DataInstance block.
Elements in this block are matched to elements in the
DataInstance block using the diffgr:id annotation.
How to add Primary key in DataSet
If we use c#DataTable dt=new DataTable();DataColumn Dc1 = new DataColumn("No", Type.GetType("System.Int32"));dt.Columns.Add(Dc1); //Set Primary key DataColumn[] dc = new DataColumn[1]; dc[0] = dt.Columns["No"]; dt.PrimaryKey = dc;
In eidt dataset designer right click on column name which u
want as primary key and set it as pk.
How to sort the data in Datatable?
pass the datatable in dataview object and call the sort
method on dataview
dataview dv=new dataview(dt)
dv.sort
that's it
I think the above answer is correct.Another one method is DataTable dt=new DataTable();DataRow[] dr=dt.Select("Filter Expression","Sort expression");Here Sort expression is , for eg.Address is one of the field in dt.Then DataRow[] dr=dt.Select("","Address ASC");But in this method is have the Datarow array.So you can use another one method,I explain below.DataView dv=new DataView(Datatable,Filter Exp,Sort Exp,Dataviewrowstate)Eg is DataView dv=new DataView(dt,"","Address ASC,DataViewVowState.CurrentRows);Here we can copy this Dataview to datatable or use this same dataview instead of datatable.
How to you declare connection strings and how to you make use of web.config ?
In web.config file just plase
Where does ADO.NET and XML web services come in the architecture ?
In 3-tier Architecture, three layers are
1. Presentation Layer -> For Only Presentation & Post the
Data to Business Object layer & Vice versa
2. Business Object Layer -> For Verfication & Posting the
Data to Data Access Layer & Vice versa
3. Data Access Layer -> Deals with the Database
Ado.Net - Comes in DAL Layer ( Data Access Layer)
XML Webservies - Comes in BOL Layer (Business Object Layer)
What's the difference between Dataset.clone and Dataset.copy?
Clone :- It only copies structure, does not copy data.
Copy :- Copies both Structure and data
How can i identify the updated rows in a dataset?
Using Rowstate property of the DataRow.
How did you design your data access layer?What should i tell for that question suppose if i use SQL server or Oracle?
The Data Access Layer, which is coming from 3-tier Architecture model.All data accessing code will maintain single entity(Data Access Layer),which is Execute NonQuery,Execute Scalar,Execute Reader and Dataset.
How do u implement locking concept for dataset?
When we update , the DataSet helps out with the process,
because it keeps track of multiple versions of rows that
have been updated. You can use parameters to set the
CommandText property of DataAdapter's UpdateCommand. The
SqlParameter class contains a property, called RowVersion,
that informs the DataSet which version of the value to make
use of. The DataAdapter judges whether the update worked by
considering whether the UPDATE statement have an effect on
zero or a non-zero number of rows. If someone else has
changed design (or deleted the row), the UPDATE returns "0
rows affected." If no one else touched the row (that is,
your optimism was justified), you receive "1 row affected."
What is method to get XML and schema from Dataset?
dataset.GetXmlSchema()
dataset.GetXML
What is the Best Practice for binding Controls [Data in the data grid is to be binded with the controls of some form ] ?
public partial class UseDataList : System.Web.UI.Page{protected DataTable GetInventory(){String strConnection =@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\northwind.mdb";DbProviderFactory f =DbProviderFactories.GetFactory("System.Data.OleDb");DbConnection connection = f.CreateConnection();connection.ConnectionString = strConnection;connection.Open();DbCommand command = f.CreateCommand();command.CommandText = "Select * from DotNetReferences";command.Connection = connection;IDataReader reader = command.ExecuteReader();DataTable dt = new DataTable();dt.Load(reader);reader.Close();connection.Close();connection.Dispose();return dt;}protected DataTable BindToinventory(){DataTable dt;dt = this.GetInventory();this.DataList1.DataSource = dt;this.DataBind();return dt;}
How can we identify the controls which can be used for binding data?
Control which drives from BaseDataBoundControl Class Serves as the base class for controls that bind to data using an ASP.NET data source control.
Advantages of ado.net?
basically ADO .Net is based on disconnected dataarchitectures unlike traditional vb 6. interactions with database is done through data command anddataset is the new concept that is in memory representationof data in xml format we can also work with xml data doc.class to segregate their contents.easy use of transactions and structured exception handling.data pis persisted in XML Format.
No comments:
Post a Comment