Showing posts with label M.C.A and all IT Students.. Show all posts
Showing posts with label M.C.A and all IT Students.. Show all posts

Tuesday, February 12, 2019

C# Unit 4 : Data Base Programming with ADO.NET for B.C.A.,M.C.A and all IT Students




-------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD – IT)
Contact No  : 7600044051
E-Mail : rupareleducation@gmail.com

C# Unit 4 : Data Base Programming with ADO.NET

Q-1     What is ADO.NET?
·        Most application requires some form of data access.
·        ADO.NET is a part of Microsoft .net framework.
·        The full form of ADO.NET is active data object.
·        ADO.NET has the ability to separate data access mechanisms data manipulation and data connectivity mechanisms.
·        ADO.NET is a set of classes that allow application to read and write information in database.
·       
Following is a diagram of ADO.NET activity:-



 

·        According to above diagram.
·        ADO.NET can be used by any .NET languages.
·        ADO.NET is concept it’s not a programming language.
·        ADO.NET introduces the concept of disconnected architecture.
·        To use ADO.NET we need to add system. Data namespace.
·         It is next version of active data object technology which is used in V.B 6.0.
·        To work with database we need to add a namespace that is……
Using system.data.sqlclient
Q-2     what is disconnected environment? Or
            Explain connected and disconnected architecture.
·        The ADO.NET framework supports two model of data access architecture.
·        That is……
1)     Connection oriented data access architecture
2)     Disconnected data access architecture.
·        In connection oriented data access architecture application make a connection to the data source and then interact with sql request using the same connection.
·        In this case the application stay connected to throw database system even when it is not using by any database operation.
·        ADO.NET solve this problem by introduce a new concept of local buffering of, persistence data using data set.
·        The data set is central component in the ADO.NET disconnected a data access architecture.
·        A database is an in memory data store that can hold multiple tables at the same time.
·        Dataset only hold data and do not interact with data source.
·        One of the key character rustics of data set is that it has no knowledge of the underline data source.
·        That night have been used to populate it.
·        To create a dataset object use following syntax:-
Dataset ds = new dataset ( );
·        According to above syntax:-
·        Dataset represent ether an entire database or a subset of database.
·        It contains tables and relationship between those tables.

Connected architecture :
1.      Command:
·        It is used to fire sql commands or perform some action on the data source.
·        Such as ……
Insert, update and delete.
·        Command object is depending on connection object.
·        Command object are use to execute command to a database across a data connection.
·        The command object in ADO.NET execute sql statements and store procedures that return single value one or more set of rows or No value at all.
·        The command object has a property called command text which contain a string value that represent the command that will be executed in the data source.
·        Command object require minimum two things.
·        That is ……
Connection and query.
·        There are four overloaded constructor.
2.      Data Reader:-
·        When we execute command object using execute reader () method at that time it return data reader.
·        Which represent forward and read only rewards?
·        Data reader is use to restive read only and for word only stream of the data from the database.
·        It means we cannot perform any insert update or delete operation in data reader.
·        Data reader is opposite of dataset
·        We cannot move previous in data reader.
·        When we just want to the data use data reader fill.
·        Data reader requires open connection.
·        Data reader can hold one table at a time.
·        Data reader has item collection.
·        Data reader has read method to read next recode.

Disconnected Architecture :
1.      Data adepter:-
·        It is associated with command and connection object.
·         The data adepter is the class at the core of ADO.NET disconnected data access.
·        It is the bridge between dataset and the database.
·        The data adepter provide a set of methods and properties to retrieve and saves data between dataset ant databases.
·        The data adepter is used fill method to fill a data table or dataset.
·        The data adepter can commit the change to database by its update method
·        Data adepter provide four properties that represent database command like,
·        Select, insert, update and delete commands etc…
·        When the data adepter fill a dataset it will create the necessary table and column for the return data.
·        It has four overloaded constructor.
2.      Data table:-
·        Dataset contain a collection of one or more data table object.
·        Data table can be identifying in the dataset using dataset table property.
3.      Data row:-
·        Data row represent a row of data in data table.
·        You can add data to the data table using data row object.
·        Data row collection object represent a collection of data row of a data table.
·        Data row class has its own properties and method. For access data base value.
4.      Data column:-
·        Data column is one part of the data row.
·        Using a dataset we can access an individual column and a value of the column from data row using data column object.
5.      Data relation:-       
·        Using a data relation we can create parent child relationship between data tables.
·        ADO.NET data table object maintain a collection of constrain like, primary key, reference key, unique key, not null etc……
·        Using a data relation object we can element redundant data with the help of join queries. 
6.      Data view:-
·        Data view work with data table.
·        Every table has a default data view.
·        With the help of data view you can create different views of the data store in data table.
·        Data view has a list of properties and methods.
·        Using data view you can expose the data in table with different shorted order and filter data.
·        Data view provides a dynamic view of single set of data.
·        Data view has important properties like, short and row filter.
·        Data view does not affect the actual data store in data table.

Q.3      ADO.NET Data Providers
The classes responsible for the movement of data between the disconnected data classes in the client application and the data store are referred to as connected classes or provider classes.

The ADO.NET Framework comes with the following providers: 

·        OLEDB: The OLEDB provider, expressed through the System.Data.OleDb namespace. You can use this provider to access SQL Server 6.5 and earlier, SyBase, DB2/400, and Microsoft Access. 

·        ODBC: The ODBC provider, expressed through the System.Data.Odbc namespace. This provider is typically used when no newer provider is available. 

·         SQL Server: The Microsoft SQL Server provider, expressed through theSystem.Data.SqlClient namespace. It Contains classes that provide functionality similar to the generic OleDb provider. The difference is that these classes are tuned for SQL Server 7 and later data access.


Q-4     Command objects method.
·        Command object has three important methods for execute queries.
·        To execute any method it need to open a connection.
·        That for…….
1)     Executescalar() method
2)     Executenonquery() method
3)     Executereader() method
·        Execute scalar it is used with agree get function.
·        Agreegaet functions are…….
1)     Avg
2)     Max
3)     Min
4)     Sum
5)     Count
·        It returns one value at a time.
·        It fetch data from database
Executenonquery Method:
·        It is use to fire insert, update and delete queries to the database.
·        It returns numbers of row affected it mean if we delete five records than it return five.
·        It is generally use in connected architecture.
ExecuteReader Method:
·        The DataReader object is a forward-only and read-only cursor.
·        It requires a live connection to the Data Source.
·        The DataReader object cannot be directly instantiated. Instead, we must call the ExecuteReader () Method of the command object to obtain a valid DataReader object.
ExecuteScalar Method:
·        The ExecuteScalar Method in SqlCommandObject returns the fist column of the first row after executing the query against the Data Source.
·        If the result set contain more than one column or rows, it takes only the first column of the first row. All other values are ignored.
·         If the result set is empty it will return a null.



Q.5      Data Binding
Windows Forms allow you to bind easily to nearly any structure that contains data. With data binding, you do not need to explicitly write the code that instantiates a connection and creates a dataset On the basis of the number of bound values that can be displayed through a control of a windows form, binding can be classified into:
  • Simple data binding
  • Complex data binding
Simple data binding
Simple data binding allows you to bind a control to a single data element. The most common use of simple data binding involves binding a single data element, such as the value of a column in a table, to a control on a form. You use this type of data binding for controls that show only one value. Uses of simple data binding include binding data to text boxes and labels.
Complex Data Binding

Complex data binding allows you to bind more than one data element to a control. Using the column example, complex data binding involves binding more than one column or row from the underlying record source. Controls that support complex data binding include data grid controls, combo boxes, and list boxes.

Q-6     Explain Grid view.
·        It displays data in grid control.
·        It means record display in row and column tabular format.
·        Grid view display record in standard format. Even we can format the row with background color.
·        It allows displaying string, data, time, number etc…….
·        Data grid view allow you to display structure data in static format as well as data from the database
·        When we bind the control to data source we can base on the structure of data source.
·        The grid view control can display data in three distinct methods.
·        That is …….
1)     Bound
2)     Unbound
3)     Virtual


:: Best Of Luck ::
Please share and comment it... Thank you.

Monday, February 4, 2019

Data Structure Unit : 2 Stack and Queue for B.C.A, M.C.A and all IT Students.


--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD-IT)
E-Mail : rupareleducation@gmail.com
Contact No : 7600044051

Data Structure Unit 2

Question:  What is Stack?
·       Stack is an abstract data type, commonly use in most programming language.
·       Stack can be categorized in static stack or dynamic stack.
·       Concept of stack are commonly used in data structure.
·       In  real word, stack allow operation at only one end the real life example of stack is plates on counters or cards.
·     According to above example , we can place or remove cards or plate from top  of the stack only.
·         At any given time, we can only access the top element of the stack.
·        It store the information on the base of LIFO system.
·        Here the element which is place last access first.
·        Following is some list of operation supported by the stack linear data structure.
  •       Push
  •       Peep
  •       Pop

Push Operation:
·        Push operation is allow user to insert an information in the stack.
·        But before inserting, we must 1st check that enough space is available or not.
·       If require space is not available then it display an appropriate message on the screen that is stack is overflow.
·        Otherwise increment in top by 1.
·       And store the data into the stack.
·       Following is a diagram of push function in stack.

Draw Diagram Here 

·        According to above diagram, If stack is empty then value of top is
-1 but here the value of top is 1 so, it allow user to input an element in to stack.
Peep Operation:
·         Peep operation of stack  is used to display all element which are exist in a stack.
·        In this operation, top traversal from top to bottom before handling this operation 1st of all we have to check that “elements are available or not in stack”.
·        If there is a no any element in the stack then the value of tos in -1 and display appropriate message on the screen that is “stack in empty”
·        Other wise it display data in LIFO manner.
·        Following is a diagram of peep operation.

Draw Diagram Here 

·       According  to above diagram, peep function allow tos to traversal from top to bottom.
·       And data displaying sequential order.
Pop  Operation:
·        This is used to removing or deleting and existing element from the stack.
·        Stack is always inserted and remove at one end It means there is no any choice for remaining an item.
·        But ,The value of tos is decrease by one to their position to lower position in the stack.
·        Before  delete or remove element from the stack check the condition that elements are available or not in a stack.
·        If stack has no any element then it display appropriate message on the screen that is stack is empty.
·        Otherwise the value of tos is -1.
·        Actually the element are store inside the array but it not display while displaying other element.
·       Following is a diagram of pop operation:

Draw Diagram Here 

·       According to above diagram, Before deleting an element from the stack the position of  tos  is at the 30.
·       And after the delete the value of tos is -1.
Means the posting to the value of 20.


Question : Applications of Stack

·        Here you will learn about applications of stack.

·        Stack is an abstract data type and a data structure that follows LIFO (last in first out) strategy. It means the element added last will be removed first. Stack allows two operations push and pop. Push adds an element at the top of the stack and pop removes an element from top of the stack.

·        Below I have mentioned few applications of stack data structure.




Applications of Stack
     ·        Expression Evaluation
Stack is used to evaluate prefix, postfix and infix expressions.
     ·        Expression Conversion
An expression can be represented in prefix, postfix or infix notation. Stack can be used to convert one form of expression to another.
     ·        Syntax Parsing
Many compilers use a stack for parsing the syntax of expressions, program blocks etc. before translating into low level code.
     ·        Backtracking
Suppose we are finding a path for solving maze problem. We choose a path and after following it we realize that it is wrong. Now we need to go back to the beginning of the path to start with new path. This can be done with the help of stack.
     ·        Parenthesis Checking
Stack is used to check the proper opening and closing of parenthesis.
     ·        String Reversal
Stack is used to reverse a string. We push the characters of string one by one into stack and then pop character from stack.
     ·        Function Call
Stack is used to keep information about the active functions or subroutines.

Polish Expression:
Polish Expression is a notation form for expressing arithmetic, logic and algebraic equations. Its most basic distinguishing feature is that operators are placed on the left of their operands. If the operator has a defined fixed number of operands, the syntax does not require brackets or parenthesis to lessen ambiguity.
Polish notation is also known as prefix notation, prefix Polish notation, 

Infix, Postfix and Prefix notations are three different but equivalent ways of writing expressions. It is easiest to demonstrate the differences by looking at examples of operators that take two operands.
For ex. : A * ( B + C ) / D

Infix notation: X + Y
·        Operators are written in-between their operands.
·        This is the usual way we write expressions.
·        An expression such as A * (B + C) / D is usually taken to mean something like: "First add B and C together, then multiply the result by A, then divide by D to give the final answer."
·        Infix notation needs extra information to make the order of evaluation of the operators clear: rules built into the language about operator precedence and associatively, and brackets ( ) to allow users to override these rules.
·        For example, the usual rules for associatively say that we perform operations from left to right, so the multiplication by A is assumed to come before the division by D.
·        Similarly, the usual rules for precedence say that we perform multiplication and division before we perform addition and subtraction.

Postfix notation (also known as "Reverse Polish notation"): X Y +

Operators are written after their operands.
The infix expression given above is equivalent to A B C + * D / .The order of evaluation of operators is always left-to-right, and brackets cannot be used to change this order.
Because the "+" is to the left of the "*" in the example above, the addition must be performed before the multiplication. 
Operators act on values immediately to the left of them. For example, the "+" above uses the "B" and "C". We can add brackets to make this explicit:  ( (A (B C +) *) D /)  Thus, the "*" uses the two values immediately preceding: "A", and the result of the addition. Similarly, the "/" uses the result of the multiplication and the "D".

Prefix notation (also known as "Polish notation"): + X Y

Operators are written before their operands. The expressions given above are equivalent to / * A + B C D as for Postfix, operators are evaluated left-to-right and brackets are sufficient. Operators act on the two nearest values on the right. It again added brackets to make this clear:  (/ (* A (+ B C) ) D)
In all three versions, the operands occur in the same order, and just the operators have to be moved to keep the meaning correct.


Queue
Que: 1 What is Queue?
·        Queue is also an abstract data type or linear data structure.
·        It help user to store data in a sequential.
·        Queue is work on FIFO manner.
·        Queue is most useful linear data structure and  use in real life, example like Queue at ticket window.
·        Queue has two pointer that is front pointer and rear pointer.
·        Front is also called head and rear called the tail.
·        Queue can be categorizes in following category.
A. Simple Queue
B. Circular Queue
C. Double Ended Queue
D. Priority Queue

Simple Queue:
·        Simple Queue represent a linear data structure to store data in a linear format.
·        Simple queue has open and close end.
·        One end is always used to insert a data while another end is always used remove data.
·        Queue follow FIFO algorithm it means data items are store 1st will be access 1st .
·        Simple queue have 3 different operation:
Push Operation
Peep Operation
Pop Operation
Push Operation:
·        Queue provide two separate value which initialize with -1 means queue is empty.
·        Push operation is generally used to insert an element in a queue.
·        But, before an inserting an element, Check the condition in a queue that enough space is available  or not.
·        If enough space is not available the it display an appropriate message on the screen that is Queue is overflow.
·        Otherwise allow to insert an element into the queue. If Inserted element was 1st then increment in front by 1 otherwise increment in rear by 1.
·        Following is  diagram of push function in a queue.
Diagram
·        According to above diagram, if Queue is empty then value of front and rear is -1.
·        While in second diagram, After inserting an element value of front and rear increment by 1.
Pop Operation:
·        Pop operation is used to remove or delete  an element in a queue.
·        Before Executing a pop operation first check the condition  that elements are available or not.
·        If queue has no any element then it display appropriate message on the screen that is queue is empty.
·        Otherwise  increment in front pointer by 1.
·        In this operation there is no any choice  from the user because  it work on FIFO manner.
·        At the time of executing ,the pop operation if there is only single element then, The value of front and rear is -1  which   denoted that queue is empty.
·        Following is diagram of pop Operation:
Diagram
·        According to above diagram, we can clearly show that the value of front is increment by 1 and remove the element in a queue.
Peep Operation:
·        This is used to display an existing element in a queue  before  handling this operation 1st check the condition .
·        If queue has no any element then it display appropriate message on the screen that is queue is empty.
·        Otherwise it traversal from Front to rear.
·        Following is diagram of Peep operation:
Diagram
·        According to above diagram, this  allow  traversal from the front to rear and display data in sequential order.

Circular Queue:
·        Circular queue is also one of the concept of linear  data structure.
·        And it provide an attractive way to insert a record in a linear  data structure.
·        It also follow the principle of FIFO  manner.
·        It means it re-allocate a space which is already used by in elements.
·        The main advantages  of circular queue  is never display overflow message on the screen.
·         In a simple queue, Once the queue is full , A new element are not allow to insert, Even after few elements, are deleted from front.
·        It not allow to insert a new element in a replace of a deleted elements.
·        While in a circular queue, allow to access the data elements space which is already deleted from the queue.
·        Following is diagram of Circular queue:
Diagram
·        According to above diagram, circular queue continuously allow to user input a new element in their buffer element.
·        Circular queue have 3 different operation:
Push Operation
Peep Operation
Pop Operation
Push operation:
·        In this queue, push operation allow user to input an element into the queue abstract data type.
·        Before inserting a new element must check the condition the require space the require space is available or not.
·        If require space is not available then it may possible to destroy all the element, from the queue and start a new queue as a element.
·        Otherwise rear pointer increment by 1 and allocate new index value to store the element.
·        Following is diagram of push operation in circular queue.
Diagram
·        According to above diagram, user can insert an element at rear pointer the rear pointer is always increment by 1.
·        If space is available otherwise destroy it.
Pop operation:
·        This is used to remove or delete an existing element from the circular queue.
·        Before executing the pop operation 1st check the condition that circular queue has element or not.
·        If there is no any element in a circular queue, then it display an appropriate message that is “Queue is empty.”
·        If circular queue is empty then the value of front and rear are -1.
·        If there are element, in a queue then it remove element, from front it means the value of front    is increment by 1.
·        It also check one another nested condition that is removed element is a last element in a queue.
·        If condition became true then the value of front & rear will be -1.
·        Following is diagram of pop operation in circular queue.
Diagram
·        According to above diagram, value of front is increment by 1 which is denoted that the element is remove from  front.
Peep Operation:
·        Peep operation is used to display all the element which are store in side the circular queue.
·        Circular queue is represent static data structure so, before display all the element check the condition that element are exist in a queue or not.
·        If there is no any element in a circular queue, then it display an appropriate message that is “Queue is empty.”
·        Otherwise it display element front to rear pointer sequentially as a linear data structure.
·        Circular queue provide some additional features to display data in circular mode.
·        That may be possible that the value of front greater than the  value of rear pointer.
·        Then data displaying two separate execution part that is front to size -1 and zero to rear.
·        Following is diagram of peep operation in circular queue.
Diagram
·        According to above diagram, peep operation display their element in 2 separate execution part that we can clearly show that in a diagram.

Double Ended Queue:
·        De–queue means Double Ended Queue.
·        It work same as like a simple queue but it provide a special mechanism to insert or remove data element to or from the queue.
·        De – queue provided insertion and deletion at either end it means de-queue element can be add or remove from the both side.
·        Following is a diagram of de-queue.
Diagram
·       According to above diagram, user can be add a new element at the rear or from the front position.
·       And some as  remove element at the rear or from the front position. That’s why it’s called the De-queue.
·       Following is some operation of De-queue :
a.                 Insert at front
b.                Insert at rear
c.                 Remove at front
d.                Remove at rear
e.                 Display from front to rear
f.                  Display from rear to front
a.     Insert at front:
·       De-queue provide two separate value which is initialize with -1 means De-queue is empty.
·       In a De-queue the inserted at front operation is generally used to insert an element at the front side.
·       It means de-queue allow insert element at both side.
·       But before inserting an element  into the de queue at front side you have to check enough space is available or not.
·       If enough space is available then it insert an element at front side into the de-queue.
·       Otherwise it display an appropriate message on the screen that is there is no enough space.
·       Following is a diagram of  insert at front in de-queue.
Diagram

·       According to above diagram, if we have space at front side then, we can simply add element at front using minus 1.
b.    Insert at rear:
·        As it is push function in simple queue.
c.      Delete at front:
·         As it is pop function in simple queue.
d.    Delete at rear:
·        This operation is used to delete an element from the rear side.
·        It allow insertion as well as delete the element 1 by 1 from the rear side.
·        When some element delete from the rear side then it traversal from 1st step then the front and rear in the same position it mean the value of front and rear on equal position and there is only 1 element in the de-queue.
·        Before delete an element from the rear 1st check the condition that element are exist in a queue or not.
·        If there is no any element then, display appropriate message on the screen that is, de-queue is empty.
·        Otherwise, rear pointer decrement by 1.
·        Following is a diagram of  delete at front in de-queue.
Diagram

·        According to above diagram, We can clearly show that if element are exist in a de-queue then it is possible to delete an element  from the rear side using r--.
e.      Display  front to rear:
·        As it is peep function in simple queue.
f.       Display Rear to front:
·        This operation is used to display an existing element in a de-queue before handling this operation 1st check the condition that element are exist in a queue or not.
·        If there is no any element then, display appropriate message on the screen that is, de-queue is empty.
·        Otherwise, it traversal from rear to front.
·       Following is a diagram of  display rear to front in de-queue.
Diagram

According to above diagram, this operation allow traversal from display rear to front and display data  in reverse order.

Priority of the Queue
·        In computer science, a priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue.
·        A Queue is a data type for storing a collection of priority wise element in which it is possible to insert or remove at any position in a queue.
·        It is Depend on it’s priority it means order of the priority that the element can access it’s information and also provide a remove operation on any time in a queue.
·        In short we can say that in a priority of the queue every element of a queue has some priority and because based on this priority it is known as priority of the queue.
A priority queue must at least support the following operations:
·        insert_with_priority: add an element to the queue with an associated priority.
·        pull_highest_priority_element: remove the element from the queue that has the highest priority.
Question: Applications of Queue
Queue, as the name suggests is used whenever we need to manage any group of objects in an order in which the first one coming in, also gets out first while the others wait for their turn, like in the following scenarios:
1.     Serving requests on a single shared resource, like a printer, CPU task scheduling etc.
2.     In real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free.
Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive i.e First come first served.


Please share and Comment it... Thank You

:: Best Of Luck ::