|
.Net Database Interview Questions and Answers
To test a Web Service you must create a windows
application or web application to consume this service?
It is True/False?
FALSE
How many classes can a single.NET DLL contain?
Answer1:
As many
Answer2:
One or more
What are good ADO.NET object(s) to replace the ADO
Recordset object?
The differences includes
In ADO, the in-memory representation of data is the
Recordset.
In ADO.net, it is the dataset
A recordset looks like a single table in ADO
In contrast, a dataset is a collection of one or more
tables in ADO.net
ADO is designed primarily for connected access
ADO.net the disconnected access to the database is used
In ADO you communicate with the database by making calls
to an OLE DB provider.
In ADO.NET you communicate with the database through a
data adapter (an OleDbDataAdapter, SqlDataAdapter,
OdbcDataAdapter, or OracleDataAdapter object), which
makes calls to an OLE DB provider or the APIs provided
by the underlying data source.
In ADO you cant update the database from the recordset.
ADO.NET the data adapter allows you to control how the
changes to the dataset are transmitted to the database.
On order to get assembly info which namespace we should
import?
System.Reflection Namespace
How do you declare a static variable and what is its
lifetime? Give an example.
Answer1
static int Myint–The life time is during the entire
application.
br> Answer2
The static modifier is used to declare a static member,
which belongs to the type itself rather than to a
specific object. The static modifier can be used with
fields, methods, properties, operators, events and
constructors, but cannot be used with indexers,
destructors, or types. In C#, the static keyword
indicates a class variable. In VB, the equivalent
keyword is Shared. Its scoped to the class in which it
occurs.
Example
a. Static int var //in c#.net
b. static void Time( ) //in c#.net
How do you get records number from 5 to 15 in a dataset
of 100 records? Write code.
Answer1
DataSet ds1=new DataSet(); String strCon=”data
source=IBM-6BC8A0DACEF;initial catalog=pubs;integrated
security=SSPI;persist” +” security info=False;user
id=sa;workstation id=IBM-6BC8A0DACEF;packet size=4096?;
String strCom1=”SELECT * FROM employee”;
SqlDataAdapter sqlDa1=new
SqlDataAdapter(strCom1,strCon);
ds1.Tables.Add(”employee”);
sqlDa1.Fill(ds1,40,50,ds1.Tables[”employee”].TableName);
DataGrid dg1.DataSource=ds1.Tables[”employee”].DefaultView;
dg1.DataBind();
Answer2
OleDbConnection1.Open()
OleDbDataAdapter1.Fill(DataSet21, 5, 15, “tab”)
This will fill the dataset with the records starting at
5 to 15
How do you call and execute a Stored Procedure in .NET?
Give an example.
Answer1
ds1=new DataSet();
sqlCon1=new SqlConnection(connectionstring);
String strCom1=”byroyalty”;
sqlCom1=new SqlCommand(strCom1,sqlCon1);
sqlCom1.CommandType=CommandType.StoredProcedure;
sqlDa1=new SqlDataAdapter(sqlCom1);
SqlParameter myPar=new SqlParameter(”@percentage”,SqlDbType.Int);
sqlCom1.Parameters.Add (myPar);
myPar.Value=40;
sqlDa1.Fill(ds1);
dg1.DataSource=ds1;
dg1.DataBind();
Answer2
Yes
Dim cn as new OleDbConnection (
“Provider=Microsoft.Jet.OLEDB.4.0;”+ _
“Data Source=C:\Documents and Settings\User\My
Documents\Visual Studio Projects\1209\db1.mdb”+ _
“User ID=Admin;”+ _
“Password=;”);
Dim cmd As New OleDbCommand(”Products”, cn)
cmd.CommandType = CommandType.StoredProcedure
Dim da As New OleDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, “Products”)
DataGrid1.DataSource = ds.Tables(”Products”)
What is the maximum length of a varchar in SQL Server?
Answer1
VARCHAR[(n)]
Null-terminated Unicode character string of length n,
with a maximum of 255 characters. If n is not supplied,
then 1 is assumed.
Answer2
8000
Answer3
The business logic is the aspx.cs or the aspx.vb where
the code is being written. The presentation logic is
done with .aspx extention.
How do you define an integer in SQL Server?
We define integer in Sql server as
var_name int
How do you separate business logic while creating an
ASP.NET application?
There are two level of asp.net debugging
1. Page level debugging
For this we have to edit the page level debugging enable
the trace to true in the line in the html format of the
page.
%@ Page Language=”vb”
trace=”true”AutoEventWireup=”false” Codebehind=”WebForm1.aspx.vb”
Inherits=”WebApplication2.WebForm1?>
2. You can enable the debugging in the application level
for this
Edit the following trace value in web.config file
Enable trace enabled=true.
If there is a calendar control to be included in each
page of your application, and and we do not intend to
use the Microsoft-provided calendar control, how do you
develop it? Do you copy and paste the code into each and
every page of your application?
Create the Calendar User Control
The control we will create will contain a calendar
control and a label which has the corresponding date and
time written
Steps are:-
Creating a CalenderControl
1) To begin, open Visual Studio .NET and begin a new C#
Windows Control Library.
2) You may name it whatever you like, for this sample
the project name will be CalenderControl
Using the Calender Control in a Windows Application
It’s just like adding any other control like a button or
a label.
1) First, create a new Windows Application project
named: CustomControl.
2) Add a reference to the Calender Control DLL named:
CalenderControl.dll.
3) Now you a can customize the Toolbox:
Right-Click the Toolbox> .NET Framework Components>
Browse> select the CalenderControl.dll.
4)The Calender Control is now added to the Toolbox and
can be inserted in Windows Form as any other control.
The control itself will take care of the date display
Page Numbers :
1
2
3
4
5
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Microsoft .Net Interview
Questions for more Microsoft .Net Interview Questions with answers
Check
Asp .Net Interview
Questions for more Asp .Net Interview Questions with answers
Check
.Net
Deployment Interview
Questions for more .Net Deployment Interview Questions with answers
|