Exploring SqlConnection in
Exploring SqlConnection in
NET
ADO.NET
The following are a few of the .NET applications that use ADO.NET to connect
to a database, execute commands and retrieve data from the database.
ASP.NET Web Applications
Console Applications
Windows Applications.
Various Connection Architectures
We can also observe various classes in the preceding diagram. They are:
1. Connection Class
2. Command Class
3. DataReader Class
4. DataAdaptor Class
5. DataSet.Class
1. Connection Class
ExecuteScalar: This method only returns a single value. This kind of query
returns a count of rows or a calculated value.
ExecuteXMLReader: (SqlClient classes only) Obtains data from an SQL
Server 2000 database using an XML stream. Returns an XML Reader object.
3. DataReader Class
4. DataAdapter Class
Or:
String constr="data source=.;initial
catalog=institute;uid=rakesh;pwd=abc@213";
Windows Authentication
String constr="server=.;database=institute;trusted_connection=true"
Or:
If you want to connect to an Oracle database, all you need to do is to change the
connection class name from SqlConnection to OracleConnection Command
class name from SqlCommand to OracleCommand
and SqlDataReader to OracleDataReader and also in the beginning use the
namespace System.Data.OralceClient.