within assembly
|
outside assembly
|
|||
with inheritance
|
without inheritance
|
with inheritance
|
without inheritance
|
|
public
|
Yes
|
Yes
|
Yes
|
Yes
|
private
|
No
|
No
|
No
|
No
|
protected
|
Yes
|
No
|
yes
|
No
|
internal
|
yes
|
Yes
|
No
|
No
|
protected internal
|
Yes
|
Yes
|
Yes
|
No
|
Saturday, April 2, 2016
Accessibility of Modifier in C#
Friday, April 1, 2016
Difference between Data Reader, Data Adapter, Dataset in C #
Data Reader
Data Reader is used to read the data from Data Base in
forward direction only Data Reader read the data in connected environment it
will fetch the data very fast as comparison to Data set.
C# code
Sqlconnection con=new Sqlconnection (“Data Source=.;
integrated security=true; initial catalog=Master”)
{
con.open( );
Sqlcommand cmd=new Sqlcommand(“select * from emp”, con);
SqlDataReader dr= cmd.ExecuteReader ();
con.close();
}
Data Adapter
Data Adapter will work as a bridge between Data Reader and
Data set, it is worked in disconnected architecture. Data Adapter is used to
read the data from database and bind the data from data base.
Data set
Data set work in the disconnected environment is the
collection of Data tables and relations between tables .It is used to hold
multiple tables with data. Data set also provides features like saving data as
XML and loading XML data.
C# code
Sqlconnection con=new Sqlconnection (“Data Source=.;
integrated security=true; initial catalog=Master”)
{
con.open( );
Sqlcommand cmd=new Sqlcommand(“select * from emp”, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new
DataSet();
da.Fill(ds);
}
Wednesday, March 30, 2016
What is the difference between ADO and ADO.Net?
ADO
|
ADO.Net
|
Used connected data usage
|
Used disconnected data environment
|
Provided by record set
|
Provided by data set
|
Data is stored in binary format
|
Data is stored in XML format
|
It is COM based library
|
It is CLR based library
|
XML integration is not possible
|
XML integration is possible
|
ADO allows to create client-side cursors only
|
ADO.NET gives you the choice of either using client-side or
server-side cursors
|
Join cannot be allow
|
Allow
|
Constraint cannot allow
|
Allow
|
Trigger cannot allow
|
Allow
|
Update multiple rows with different values SQL server
In this article I am going to explain how to update multiple row with
different value by single Update Statement in SQL.
Here I am creating two table and by these two table I will update employee table "salary column" value according to employee department with the help of "salary" table
Here I am creating two table and by these two table I will update employee table "salary column" value according to employee department with the help of "salary" table
CREATE
TABLE Employee
(
EmpId INT
identity(1,
1)
,NAME
VARCHAR(50)
,Department
VARCHAR(20)
,Salary
MONEY
)
|
create
table salary
(
Department
VARCHAR(20)
,Salary
MONEY
)
|
Employee Table Data
Salary Table Data
Now I am writing a single update statement, which update employee salary
according to department by the use of "salary" table.
UPDATE
t1
SET
t1.Salary =
t2.Salary
FROM
Employee AS t1
INNER
JOIN salary AS
t2 ON t1.Department
= t2.Department
|
After executing above update query the employee table look like
What is difference between Dispose and finalize method in c#?
Dispose
Method ()
-
Dispose method belong to the IDisposable
interface
-
Dispose method will be used to free unmanaged
resource like files, database connections etc.
-
To clear unmanaged resource we have to
manually write the code to implement it.
-
It is faster method
-
Syntax of this method is void Dispose()
Finalize
Method ()
-
Finalize method belong to the object
class.
-
It is automatically raised by garbage
collection mechanism when the object goes to scope.
-
It is slower method
-
Syntax for this method is protected
virtual void Finalize()
Subscribe to:
Posts (Atom)