Upload
vaibhav-vasani
View
68
Download
2
Embed Size (px)
Citation preview
Compiled By Prof. Vaibhav Vasani
Sample Paper 4 (MSBTE)
Q1 Attempt any four:
A)List 4 Advantages of DOTENET Technology. Ans. .NET Framework Advantages
The .NET Framework offers a number of advantages to developers. i)Consistent Programming Model :-
Different programming languages have different approaches for doing a
task. The difference in techniques comes from how different languages interact with the underlying system that applications rely on.
With .NET, for example, accessing data with a VB .NET and a C# .NET looks very similar apart from slight syntactical differences. there is more than one way to do a particular task within the same language.
The .NET explains that there's a unified means of accomplishing the same task by using the .NET Class Library, a key component of the .NET
Framework. The functionality that the .NET Class Library provides is available to all .NET languages resulting in a consistent object model regardless of the programming
language the developer uses. ii) Direct Support for Security :-
Consider an application that accesses data on a remote machine or has to perform a privileged task on behalf of a non privileged user. In this scenario
security is much more important as the application is accessing data from a remote machine.
With .NET, the Framework enables the developer and the system
administrator to specify method level security. It uses industry-standard protocols such as TCP/IP, XML, SOAP and HTTP to facilitate
Distributed application communications. This makes distributed
computing more secure because .NET developers cooperate with network security devices instead of working around their security limitations.
iii) Simplified Development Efforts :-
ASP.NET and the .NET Framework simplify development by separating
the application logic and presentation logic making it easier to maintain the code.
You write the design code (presentation logic) and the actual code (application logic) separately
code. ASP.NET can also handle the details of maintaining the state of the
controls, such as contents in a textbox, between calls to the same ASP.NET page.
Compiled By Prof. Vaibhav Vasani
Another advantage of creating applications is debugging. Visual Studio .NET and other third party providers provide several debugging tools that
simplify application development. The .NET Framework simplifies debugging with support for Runtime diagnostics.
iv) Easy Application Deployment and Maintenance :-
The .NET Framework makes it easy to deploy applications. In the most
common form, to install an application, all you need to do is copy the application along with the components it requires into a directory on the target computer.
The .NET Framework handles the details of locating and loading the components an application needs, even if several versions of the same
application exist on the target computer.
The .NET Framework ensures that all the components the application
depends on are available on the computer before the application begins to execute.
B)List DataType Supported by VB.NET with their Storage byte length Ans.
DataType Size in Bytes
Byte 1
Char 2
Integer 4
Long 8
Short 2
Single 4
Double 8
String variable
Date 8
Boolean 2
Object 4
Decimal 16
C)Compare Procedure and Function used in VB.NET with Example.
Ans.
Sub Procedures
Function
Sub procedures are methods which do not return a value
Function returns a value
Declared with the Sub keyword Declared with the Function keyword
Compiled By Prof. Vaibhav Vasani
the statements within it are executed
until the matching End Sub is encountered
the statements within it are executed
until the matching End Function is encountered
Example of a Sub Procedure: Module Module1
Sub Main () „Sub procedure Main () is called by default Display ()
„Sub procedure display () which we are creating End Sub
Sub Display ()
System.Console.WriteLine ("Using Sub Procedures")
„Executing sub procedure Display () End Sub
End Module
Example on Functions: Imports System. Console
Module Module1 Sub Main ()
Write ("Sum is" &” " & Add ()) 'Calling the function
End Sub
Public Function Add () As Integer
'Declaring a function add
Dim i , j as Integer 'Declaring two integers and assigning values to them
i = 10 j = 20 Return ( i + j)
'Performing the sum of two integers and returning its value End Function
End Module
d)What is XML and Describe creation of XML file. Ans.
Compiled By Prof. Vaibhav Vasani
XML (Extensible Markup Language) is a set of rules for encoding documents electronically.
It is defined in the XML 1.0 Specification produced by the W3C and several other related specifications; all are fee-free open standards.
XML unlike HTML allows us to create our own Tags.
XML is case sensitive language. XML can be use to store data as like in database. The XML schema contains whole information about the relation structure. It
contains information regarding table, constraints and relation.
Creation of XML file. In VB.NET XML file can be added to any Solution
1. Right clicking on Solution in Solution Explorer 2. Click on “Add new item” 3. Then select XMLFile.xml From window which is displayed
4. Then XML file is added in project
XML Declaration XML documents may begin by declaring some information about them, as in the following example.
<?xml version="1.0" encoding="UTF-8" ?>
Example
Here is a small, complete XML document, which uses all of these constructs and concepts.
<? xml version="1.0" encoding='UTF-8'?>
<Students> <Student> <Name>ABC</Name>
<Roll>11</Roll> </Student>
<Student> <Name>PQR</Name> <Roll>22</Roll>
</Student> </Students>
e)What is Web Application State necessity of Web Application? Ans.
Compiled By Prof. Vaibhav Vasani
A web application is an application that is accessed via a web browser over a network such as the Internet or an intranet. The term may also mean a computer
software application that is hosted in a browser-controlled environment (e.g. a Java applet) or coded in a browser-supported language (such as JavaScript, combined
with a browser-rendered markup language like HTML) and reliant on a common web browser to render the application executable.
Web applications are popular due to the ubiquity of web browsers, and the convenience of using a web browser as a client, sometimes called a thin client.
The ability to update and maintain web applications without distributing and installing software on potentially thousands of client computers is a key reason for their popularity, as is the inherent support for cross-platform compatibility.
Common web applications include webmail, online retail sales, online auctions, wikis and many other functions.
Browser applications typically require little or no disk space on the client,
upgrade automatically with new features, integrate easily into other server-side web procedures, such as email and searching. They also provide cross-platform compatibility (i.e., Windows, Mac, Linux, etc.) because they operate within a
web browser window.
These programs allow the user to pay a monthly or yearly fee for use of a software application without having to install it on a local hard drive.
f)What are Method, Event, Collection, Object in ASP.Net?
Ans. Methods:
Represent the object‟s built-in procedures. It is set or block of Statements. You define methods by adding procedures, Sub routines or
functions to your class. Two types of method are
Sub-Procedure: A procedure with no return value
Function: A procedure with return value
Event: Events allow objects to perform actions whenever a specific occurrence
takes place. For example when We click a button a click event occurs and we
can handle that event in an event Handler.
Collection:
A namespace is a collection of different classes. All VB applications are developed using classes from the .NET System namespace. The namespace
Compiled By Prof. Vaibhav Vasani
with all the built-in VB functionality is the System namespace. All other namespaces are based on this System namespace
Object:
Object is an instance of a class; Object contains properties defined by class Multiple objects of same class can be created like variables and destroyed Each class defines DataType
Q2. Attempt any three:
1. Describe if and select case statement with example. Ans:
If If conditional expression is one of the most useful control structures which allows us to execute a
expression if a condition is true and execute a different expression if it is False. The syntax looks like
this: If condition Then
[statements] Else If condition Then [statements]
- -
Else [statements] End If
Understanding the Syntax If the condition is true, the statements following the Then keyword will be
executed, else, the statements following the ElseIf will be checked and if true, will be executed,
else, the statements in the else part will be executed.
Example: Imports System.Console
Module Module1 Sub Main() Dim i As Integer
WriteLine("Enter an integer, 1 or 2 or 3") i = Val(ReadLine()) 'ReadLine() method is used to read from console
Compiled By Prof. Vaibhav Vasani
If i = 1 Then WriteLine("One")
ElseIf i = 2 Then WriteLine("Two")
ElseIf i = 3 Then WriteLine("Three") Else
WriteLine("Number not 1,2,3") End If End Sub
End Module
Select....Case Statement The Select Case statement executes one of several groups of statements depending on the value of an
expression. If your code has the capability to handle different values of a particular variable then you can use a Select Case statement. You use Select
Case to test an expression, determine which of the given cases it matches and execute the code in that matched case. The syntax of the Select Case statement looks like this:
Select Case testexpression [Case expressionlist-n
[statements-n]] . . . [Case Else elsestatements]
End Select Example:
Imports System.Console Module Module1
Sub Main() Dim keyIn As Integer
WriteLine("Enter a number between 1 and 4") keyIn = Val(ReadLine()) Select Case keyIn
Case 1 WriteLine("You entered 1")
Case 2 WriteLine("You entered 2") Case 3
WriteLine("You entered 3") Case 4 WriteLine("You entered 4")
Compiled By Prof. Vaibhav Vasani
End Select End Sub
End Module
2. Write VB.NET application using command button and textbox to read number and calculate factorial of the number.
Ans: Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click Dim s As String
Dim i, f As Integer f = 1 i = 1
s = TextBox1.Text While i <= s
f = f * i i = i + 1 End While
TextBox1.Text = "Factorial is :" & f End Sub
End Class
3. Explain the purpose of data adapter control. How does a data adapter differ from a connection? What is Dataset? Ans:
The DataAdapter is the class at the core of ADO.NET‟s disconnected data access. It is essentially the middleman facilitating all communication between the database and a Dataset.
The DataAdapter is used either to fill a DataTable or Dataset with the data from the database with it‟s Fill method. After the memory –resident data
has been manipulated the DataAdapter can commit the changes to the database by calling the Update method. The DataAdapter provides four properties that represent database commands:
1. Select Command 2. Insert Command
3. Delete Command 4. Update Command
Difference between DataAdapter and Connection The Connection object creates the connection to the database whereas the DataAdapter is used to fill the DataTable or Dataset with Data.
Compiled By Prof. Vaibhav Vasani
There are two types of Connection objects provided by.NET:
1. SqlConnection 2. OledbConnection
The DataAdapter provides four properties that represent database commands: 1. Select Command 2. Insert Command
3. Delete Command 4. Update Command
DataSet: The Dataset is a disconnected in-memory representation of data. It can
be considered as a local copy of the relevant portions of the database. The Dataset is persisted in memory and the data in it can be manipulated and updated independent of the database. When the use of this dataset is finished,
changes can be made back to the central database for updating. The data in Dataset can be loaded from any valid data source like
Microsoft SQL server , an Oracle database or from Microsoft Access Database. 4. Write VB.NET project to display name in drop down list, when user select a
name display the data for the rest of the field in bound label from publisher table from the Biblio.mdb database file.
Q.3.Attempt any 3
(a) What is Transaction and how transaction database is designed?
Ans:
“A Transaction is an atomic unit of work that either fails or succeeds as a
whole”. In a transaction there can be many things to do, like update one thing,
delete another, send email, response query and so on. If transaction is
successful, all of these things will be done or executed as the case may be or if
transaction fails then none of them will be executed.
When a transaction is successful, it is said that this transaction has
committed and all the tasks that it had to do will be done.
If there is some error then the whole transaction will be brought back to
its original state and none of task that it had to do will be completed, it is
called rolling back of the transaction.
Transactions are always executed as a „whole‟. A transaction symbolizes
code or a set of components or procedures which must be executed as a unit.
Compiled By Prof. Vaibhav Vasani
All the methods must execute successfully or the complete unit fails. A
transaction can be described to cover the ACID properties for mission critical
appliances.
(b) Explain the steps necessary to bind single control such a label to field
in a dataset.
Ans:
1. Open the new windows application in visual studio 2005
2. Place the label control from toolbox on the form.
3. Select the text option of data-binding property of label.
4. While selecting text option it will ask for data-source, select „add
project data-source‟.
5. After that, choose data-source type as Database from Data source
Configuration Wizard and click NEXT .
6. Choose Data-Source Connection by clicking on New Connection
button, further it will display the Add Connection dialog box, in that
choose the Database file name by selecting the browse button and then select
the respective database file.
7. Test the connection to database through Test Connection Button.
8. After the test connection is succeeded, choose your database object by
selecting the field from the table which u want to bind to the label
control. Then click on Finish button.
9. Since the Database have been included, now it will show the Other
Data sources option in the text property. In that select the other data sources,
project data sources, Dataset, data table, Field.
10. At last, run your windows application. It will display the respective
field in the label.
Compiled By Prof. Vaibhav Vasani
(c)The Rnebook.mdb database file holds two table, the book table and
subject table. The subject table has only two fields: the subject code(the
key) and the subject name. write a project that display the subject table in
grid.
Ans: 1. Open the new windows application in visual studio 2005
2. Place the Data-Grid control from toolbox on the form.
3. Select the Data-source property of Data-Grid Control.
4. While selecting Data-source option it will ask for data-source, select
„add project data-source‟.
5. After that, choose data-source type as Database from Data source
Configuration Wizard and click NEXT .
6. Choose Data-Source Connection by clicking on New Connection
button, further it will display the Add Connection dialog box, in that
choose the Database file name by selecting the browse button and then select
the respective database file.
7. Test the connection to database through Test Connection Button.
8. After the test connection is succeeded, choose your database object by
selecting the table which u want to bind to the Data-Grid control. Then click on
Finish button.
9. It will show the Binding source including the name of table.
10. At last, run your windows application. It will display the respective
table in the Data-Grid.
Compiled By Prof. Vaibhav Vasani
4. Create a web project using ASP.NET to display 10 pages on web document
using content linker also describe content linking list file.
Q.4 Attempt Any Four.(16)
a. What is CLI, CLR, CTS, CLS, IL, JIT related to DOT NET framework ?
ANS:-
Comman Language Runtime (CLR) :- The runtime engine that executes managed code. It provides core
services such as Memory and thread management , type verification and
garbage collection ; consequently, developers no longer have to worry about
such things when it comes to managed code.
Running code under CLR isolates it from the operating system,
which improve security and robustness. Managed code is complied into the
CPU –independent MSIL (Microsoft Intermediate Language) instruction set,
which is then converted to CPU specific code by runtime. Unmanaged code
runs outside of the runtime and lacks the security of managed code. A major
goal of the .Net framework is to promote and facilitate code reusability.
Just In Time Complier (JIT):- At execution time, a just in time (JIT) Complier translates the MSIL
into native code. The process like this, when .NET programs are executed, the
CLR activates the JIT complier. The JIT complier translates MSIL into native
code on demand basis as each part of the program is needed.
Comman Type System (CTS):-
Compiled By Prof. Vaibhav Vasani
To support multiple languages on a single CLR and have the ability
to reuse the FCL, the types of each programming language must be compatible.
This binary compatibility between language types is called the Comman Type
System(CTS).
Because the CLR is controlling your source code anyway . The
.NET framework does this through its common type system(CTS), which defines
all of the core data types and data mechanism used in .NET programs. This
includes all numeric, string and Boolean value types. It also defines the object,
the core data storage unit in .NET.
The CTS divides all data objects into two buckets. The First bucket
called VALUES TYPES, and the second bucket contains REFERENCE TYPES.
Comman Language Specification (CLS):- For programming languages to communicate effectively, targeting
IL is not enough. There must be a common set of standards to which every
.NET language must adhere. This common set of language features is called
the Comman Language Specification(CLS). The CLS defines a minimum set of
features that a language must implement before it is considered to be .NET
compliant or more accurately, CLS- compliant.
Microsoft Intermediate Language (MSIL):- When the .NET program is compiled, the output of compiler is not
an executable code but a file that contains a special type of code called
Microsoft Intermediate Language (MSIL).This MSIL defines a set of portable
instructions that are independent of any specific CPU. It‟s the job of CLR to
translate this intermediate code into excitable code when program is executed
making the program to run in any environment for which the CLR is
implemented. And thus the .NET Framework achieves Portability.
b. Describe the process of connecting to SQL server database; Olebd
datasource.
c. create a web page for entering the new customer Information. Validate
that all fields contain Information.
ANS:-
<%@Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
Compiled By Prof. Vaibhav Vasani
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<h1>New Customer Information</h1>
<div style="table-layout: fixed">
<asp:Label ID="Label1" runat="server" Style="left: 330px; position:
absolute; top: 208px"
Text="EMAIL"></asp:Label>
<asp:Label ID="Label4" runat="server" Style="left: 335px; position:
absolute; top: 358px"
Text="PASSWORD"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Style="left: 447px; position:
absolute;
top: 135px"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" Style="left: 454px; position:
absolute;
top: 280px"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" Style="left: 454px; position:
absolute;
Compiled By Prof. Vaibhav Vasani
top: 353px" TextMode="Password"></asp:TextBox>
<asp:TextBox ID="TextBox5" runat="server" Style="left: 462px; position:
absolute;
top: 429px" TextMode="Password"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Style="left: 449px; position:
absolute;
top: 205px"></asp:TextBox>
<asp:Label ID="Label3" runat="server" Style="left: 334px; position:
absolute; top: 286px"
Text="USERNAME"></asp:Label>
<asp:Label ID="Label2" runat="server" Style="left: 330px; position:
absolute; top: 132px"
Text="NAME"></asp:Label>
<asp:Label ID="Label5" runat="server" Style="left: 349px; position:
absolute; top: 436px"
Text="CONFIRM"></asp:Label>
<asp:Button ID="Button1" runat="server" Style="left: 441px; position:
absolute; top: 508px"
Text="SUBMIT" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate ="Textbox1" Text="You must enter the name"
ErrorMessage="RequiredFieldValidator" style="left: 655px; position: absolute;
top: 130px"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate ="Textbox2" Text="You must enter the user email"
ErrorMessage="RequiredFieldValidator"
Style="left: 648px; position: absolute; top:
200px"></asp:RequiredFieldValidator>
Compiled By Prof. Vaibhav Vasani
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate ="Textbox3" Text="You must enter the username"
ErrorMessage="RequiredFieldValidator"
Style="left: 653px; position: absolute; top:
277px"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate ="Textbox5" Text="You must enter the same password to
confirm" ErrorMessage="RequiredFieldValidator"
Style="left: 638px; position: absolute; top:
424px"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate ="Textbox4" Text="You must enter the Password"
ErrorMessage="RequiredFieldValidator"
Style="left: 646px; position: absolute; top:
352px"></asp:RequiredFieldValidator>
</div>
</form>
</body>
</html>
OUTPUT:-
Compiled By Prof. Vaibhav Vasani
d. Write Asp.Net form to display code of displaying information of C drive.
Ans:-
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Dim fso = Server.CreateObject("Scripting.FileSystemObject")
Dim d = fso.getDrive("C:\")
Response.Write(" <br/>Availble space on c: is : " & d.availableSpace)
Response.Write(" <br/>Drive Letter of c: is : " & d.driveLetter)
Response.Write("<br/>Drive Type is : " & d.driveType)
Response.Write("<br/>Free space on c: is : " & d.freeSpace)
Response.Write("<br/>File System on c: is : " & d.fileSystem)
Compiled By Prof. Vaibhav Vasani
Response.Write("<br/>Path Of c: is : " & d.path)
Response.Write("<br/>Readiness of drive: is : " & d.isReady)
%>
</div>
</form>
</bod
OUTPUT:-
e. What is post back? When does it occur? How can you keep a web
application from recreating list data when a post back occurs?
ANS:
This property is used to check whether the page is being loaded and
accessed for the first time or whether the page is loaded in response to the
client postback.
When an event is triggered, for instance, a button is clicked, or an item
in a grid is selected, the page is submitted back to the server for processing,
along with information about the event and any preexisting data on the page
(via view state). We say the page “posts back” to the server. This is a powerful
Compiled By Prof. Vaibhav Vasani
concept to grasp because it is postback that lets us run code on the server
rather than on the client‟s browser, and it is postback that lets our server code
know which items within a drop-down list were selected, or what information a
user typed into a text box.
But what would happen if you had multiple DropDownList controls that
were populated with database data? Users could interact with those
DropDownList controls and, in turn, we could set certain options within the
page based on what they selected from the drop-down menus. Although this
seems like a common task, with traditional ASP it incurred considerable
overhead. The problem is that while the data that‟s bound to the drop-down
menu from the database never changes, every time the user selects an item
from the drop-down menu and a postback has to be done, the database must
be accessed again to rebuild the contents of each drop-down list on the page.
e.g
Make 2 DropDownLists and Write in Default.aspx.vb
Make AutoPostBack=”true” of 2 DropDownLists
Partial Class _Default
Inherits System.Web.UI.Page
Dim fs = Server.CreateObject("Scripting.FileSystemObject")
Dim fs1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim f1
For Each f1 In fs.drives
DropDownList1.Items.Add(f1.driveletter)
Next
End Sub
Compiled By Prof. Vaibhav Vasani
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
DropDownList2.Items.Clear()
Dim loop1 As Integer
Dim str As String
For loop1 = 0 To DropDownList1.Items.Count - 1
If DropDownList1.Items(loop1).Selected Then
str = DropDownList1.SelectedItem.ToString
fs1 = fs.getfolder(str)
End If
Next
Dim fd
For Each fd In fs1.SubFolders
DropDownList2.Items.Add(fd.name)
Next
End Sub
End Class
f. Describe Data grid control of ADO.NET and give example how it is to be
connected with database.
ANS:
A data bound list control that displays the items from data source in a
table. The DataGrid control allows you to select, sort and edit these items.
Different column types determine the behavior of the column ion the
control. The different column types that can be used are as follows:-
BoundColumn
Compiled By Prof. Vaibhav Vasani
ButtonColumn
EditCommandColumn
HyperLinkColumn
TemplateColumn
Following program demonstrates the connection of database to datagrid:-
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<%@ Import Namespace ="System.data.oledb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<script runat ="server" >
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim con As New
OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\Employee.mdb;")
Dim cmd As New OleDbCommand("select * from emp", con)
con.Open()
DataGrid1.DataSource = cmd.ExecuteReader
DataGrid1.DataBind()
con.Close()
End Sub
Compiled By Prof. Vaibhav Vasani
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:DataGrid ID="DataGrid1" runat="server">
</asp:DataGrid></div>
</form>
</body>
</html>
<asp:datagrid runat="server"></asp:datagrid>
OUTPUT:-
Q. 5. Attempt any three.
a. Describe how to fill data set with data form multiple table. Ans.
A single dataset can contain multiple tables . To create dataset that contain multiple tables by following steps:-
Compiled By Prof. Vaibhav Vasani
Import the namespaces that are necessary.
Create the connection objects of the databases of tables that you want to fill into one dataset.
Open the connections. Create the command objects . Create the dataAdapter objects which are the same as the number
of tables one wat to fill to one dataset. Create dataset object. Fill the data set using fill method
As follow:= adap1.Fill(datasetobj, "tablename")
fill all the tables using corresponding dataAdapter Object . Drag the datagridviews depending upon the number of tables. Set the datagridview‟s DataSource property to dataset.
Imports System.Data.OleDb
Imports System.Data Public Class Form1
Dim con, con1 As OleDbConnection Dim com1, com2, com3 As OleDbCommand
Dim adap1, adap2, adap3 As OleDbDataAdapter Dim dset As New DataSet
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
„create the connection
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Book.mdb;") con1 = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\employee.mdb;")
„Open the connection con1.Open()
con.Open() com1 = New OleDbCommand("Select * from Book1", con) com2 = New OleDbCommand("Select * from Subject", con)
com3 = New OleDbCommand("Select * from emp", con1) adap1 = New OleDbDataAdapter(com1)
Compiled By Prof. Vaibhav Vasani
adap2 = New OleDbDataAdapter(com2) adap3 = New OleDbDataAdapter(com3)
adap1.Fill(dset, "Book1") adap2.Fill(dset, "Subject") adap3.Fill(dset, "emp")
DataGridView1.DataSource = dset.Tables("Book1") DataGridView2.DataSource = dset.Tables("Subject")
DataGridView3.DataSource = dset.Tables("emp") End Sub
End Class
OUTPUT:
B. Explain how session object can be used to enabled and disable a
session.
ANS: Disable Session State:
Compiled By Prof. Vaibhav Vasani
To disable a session state, we have two methods:
1. At the Application Level:
The following steps demonstrate how to disable session state at the
application level,which affects all pages in the application:
1: start Microsoft Visual Studion .NET and create a new ASP.NET Web Application
2: In the Solution Explorer , double -click Web.config to viewthe contents of this file.
3 : Locate the <SessionState> section and set the mode value to off. 4: Save the file and/or the project to disable session state through all pages in the application.
2. At the page Level :
The Following steps demonstrate how to disable session state at the page level ,which affects only the specific pages that enable these changes: 1: Start Microsoft Visual Studio.NET and create a new ASP>NET web
Application. 2: In Solution Explorer, double click the Web Form for which you want to disable session state.
3: Click the HTML tab. 4: At the top of the page, add EnabledSessionState=”false” in the @ Page
directive. The modified attribute should appear similar to the following: <%@ Page language=”c#” Codebehind=”WebForm1.aspx.cs” AutoEventWireup=”false”%>
5. Save the fil;e and/or project to disable session throughout all pages in the application.
3. Enabled Session State :
Similarly you can enable the session state at paghe level using true value for EnablesSession state or at application level by using mode value ON.
Properties of a Session Object
Some of the properties of session object are listed below . 1. Session.TimeOut Property :
The Session.TimeOut property can be used to set the expiration time in minutes for the session . If the user does not refresh the page opr request another page within the alloted time, the session is automatically
terminated and the resources are released. The default is 20 minutes. This property is mostly used in many online banking systems, to avoid misusage.
Compiled By Prof. Vaibhav Vasani
c.Write ASP.NET code to display all files form all folders of C:
Ans:
Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click Dim fso = Server.CreateObject("Scripting.FileSystemObject")
Dim j, k Dim a = "d:"
Dim d = fso.getDrive(a) Dim fd = fso.getfolder(d)
For Each j In fd.subfolders
Response.Write("<b><u>" & "+" & j.name & "</u></b>") Response.Write("<br/>") Response.Write("<br/>")
For Each k In fd.files Response.Write(" - " & k.name)
Response.Write("<br/>")
Next Response.Write("<br/>") Response.Write("<br/>")
Next End Sub End Class
OUTPUT:
Compiled By Prof. Vaibhav Vasani
d.Describe the method and properties of Application object with supporting example. ANS:
Methods and properties of Application object : Methods:
1. Application.Set Method :
Set an application state object by name or index. Syntax : Application.Set(Key,item)
Example : Setting the application veriables.
2. Application .Count method : This method is used to count the number of items (variables) of
application objects.
Example : Returns all the application keys.
Compiled By Prof. Vaibhav Vasani
3. Application .Lock Method :
The Lock method prevents all other users from making change in
any of the variables in the Constents collection of the Application object. Application objects are designed to allow only one user at a time to make changes and you do this by locking everybody else out.
It is used to unlock the Application object after it has been locked with the Lock method. If you do not unlock the application it will be unlocked after application ends or when a timeout is received.
Syntax: Application.Lock
4. Application .UnLock Method : The Application lock method can be used to lock the application object so that no actions take place on the server. The Unlock method
is used to explicitly unlock the variables in the collection of the Application object.
In contrast , the lock method prevents all other users from changing any variables in the contents collection of the Application object. While the application is locked, no pages will be served to
visitors and no ASP code will be run. If you do not unlock the applokcation it will remain locked.
Syntax: Application.UnLock
5: Application.RemoveALL() Method: This Method can be used to remove all items from an Application Object . It does not take any parameter or returnk
anything.
6: Application.Remove(name|index) Method:
This method can be used to remove specific items from Application Object .You may use only one of the two possible choices for mandatory
argument. Syntax: Application.Remove(Name or Integer)
The name argument of the item to be deleted. It must be enclosed in a pairs of quotes. The Integer argument is the position number of the item in the
collection to be deleted. The numbering swquence for a collection start at one, not zero
Q. 6. Attempt any 3
1. Describe server object used in asp programming.
Compiled By Prof. Vaibhav Vasani
2. Create an advertisement for 4 companies using ADRotator Oject. 3. Write steps for binding datagrid to a control step by step.
4. What is parameterized query, when is it used , when multiple adapters are needed illustrate with example.