Your Ad Here

25 May 2008

Visual Basic Interview Questions 3

41 What is the difference between change event in normal combo box and dbcombobox?
42 To populate a single column value which dbcontrols you to use?
DBList or DBCombo
43 What is ODBC?
It defines a method for connecting to Data Sources that are open to many
Application. To accomplish this task, the application and the database must agree
on a comman method of accessing database. This agreement is implemented using
Complete set of API calls and complete SQL syntax set.
Four major components of ODBC.
1) Data Source
2) Driver
3) Driver Manager
4) Application
44 Parts of ODBC?
a) Application
b) Driver Manager
c) Driver
D) Data Source
45 What is DSN?
Data Source Name is an acronym. When DSN is created, the associated driver
will also be embedded with it.
46 What is ODBC Direct and Microsoft Jet Database Engine ?
ODBC Direct:
It allows accessing ODBC datasources through the RDO and DAO objects
by passing Jet Database Engine.
Microsoft Jet Database Engine:
This engine is what actually reads, writes and modifies the database
and handles all the house keeping chores like indexing & security etc.
47 What do you mean by Databound Controls? Explain.
Data-bound controls can easily bind with data components. DataSource and
DisplayMemeber are two important properties.
DataSource property of these controls plays a major role. You can set
different kind of data components as datasource property of a control
DisplayMember property can be set to a database table field name if you
want to bind a particular field to the control.
Eg:
DataGrid
DataList
DataCombo
48 Difference between Linked Object and Embedded Object?
Linking (OLETypeAllowed=Linked(0)):
a) Data associated with a linked object is manipulated by the
OLE server application and stored outside on OLE container.
b) Stores the name of the application that supplied object &
reference to the data.
Embedding (OLETypeAllowed=Embedded(1)):
a) Data associated with an embedded object is contained in an
OLE container control and data can be saved with your VB
application.
b) It stores the name of the application that supplied the
objects along with its data.
49 Difference between DDE and OLE.
OLE:
Embedding other application on form that compiles the Object Linking and embedding Protocals.
DDE:
A method of exchanging data between applications on MacOS, Windows, and OS/2 operating systems. DDE is similar to OLE, but predates it. It enables multiple applications to have access to the same data, such as a word processor having data from a spreadsheet pasted into it. Changes made in either application to the data are reflected in the main document.
Acronym for Dynamic Data Exchange, an interprocess communication (IPC) system built into the Macintosh, Windows, and OS/2 operating systems. DDE enables two running applications to share the same data. For example, DDE makes it possible to insert a spreadsheet chart into a document created with a word processor. Whenever the spreadsheet data changes, the chart in the document changes accordingly. Although the DDE mechanism is still used by many applications,it is being supplanted by OLE, which provides greater control over shared data.
50 What is the difference between Object and Class?
OBJECT:
a) Object is nothing but instance the class.
b) Objects are units of code and data.
c) Object variables can be two types
i) Generic-can store all types of object
ii) Specific - can store objects of the same type only.
Eg:
Dim V as Object
Dim C as Control
CLASS:
a) Its a collection of objects
b) To bind the data and methods into a single unit
51. Does VB Supports OOPS Concepts? Explain..
52 Difference between Class Module and Standard Module?
Class Module:
============
Data in a class exist seperately for each instance of the class.
It has two events, Initialize and Terminate
a) It produces reusable code.ie once a class module is defined and
implemented, it can be used by application.
b) Class Modules can be Instantiated.

Standard Module:
===============
a) Standard modules are containers for procedures and declarations
commonly accessed by other modules within the application.
b) They can contain global level declaration of variables, constants,
Types and Global procedures.
c) This wil have an extension as .bas
There is never more than one copy of a standard module's data.
This means that when one part of your program changes a public variable
in a standard module, it will get the same value.
53 What is ActiveX? Explain.
ActiveX is the set of technologies that allow separately compiled
components to communicate with one another. It allows you to develop components in many different languages such as VC++, Java, Excel, and Visual Basic and have all of the components work together.You may have built ActiveX components with VB4, but way back then () they were called OLE servers. The ActiveX technology in VB5 provides some additional features beyond those provided by the OLE servers in VB4. You can develop threaded components, add non-modal forms to ActiveX DLL components, raise events, have Friends, implement multiple interfaces,
define global objects and create ActiveX controls and ActiveX documents.
54 Types of ActiveX Components in VB?
Types of ActiveX Components:-
i) Server - ActiveX Dll, ActiveX Exe
ii) Control - ActiveX Controls,
iii) Document - ActiveX Document Dll, ActiveX Document Exe
55 What is ActiveX Control?
An ActiveX control is a standard user interface element that you can
create. These elements can be used in any container that supports ActiveX
controls, such as Visual Basic forms, Excel forms, and VC++. They are different from other ActiveX components in that they normally have a visual component like a combo box or set of text boxes.
Normally, if you are going to define business rules you do that in
ActiveX EXE or ActiveX DLL components and not in ActiveX controls.
56. What are types of ActiveX control?
a) Enhancement to existing VB controls
b) New control built with constituent control
c) User Drawn control
57 Difference between ActiveX Control and Standard Control.
An ActiveX control is a standard user interface element that you can create. These elements can be used in any container that supports ActiveX controls, such as Visual Basic forms, Excel forms, and VC++. They are different from other ActiveX components in that they normally have a visual component like a combo box or set of text boxes.Normally, if you are going to define business rules you do that in ActiveX EXE or ActiveX DLL components and not in ActiveX controls.
58 What is instantiating?
The process of creating server at client side in order to use it.
When a server is instantiated, the client can get to all properties, events,
methods and object that are made visible by the server.
59 Difference Types of Instancing Property in ActiveX Dll and Exe.
1. Private
2. PublicNotCreatable
3. SingleUse
4. MultiUse
5. GlobalSingleUse
6. GlobalMultiUse
The value of the Instancing property determines whether your class
is private - that is, for use only within your component - or available
for other applications to use.
As its name suggests, the Instancing property also determines
how other applications create instances of the class. The property
values have the following meanings.

Private:
Other applications are not allowed access to type library
information about the class, and cannot create instances of it.
Private objects are only for use within your component.
PublicNotCreatable:
Other applications can use objects of this class only if your
component creates the objects first. Other applications cannot use the
CreateObject function or the New operator to create objects from the class.
MultiUse:
Allows other applications to create objects from the class.
One instance of your component can provide any number of objects created
in this fashion. An out-of-process component can supply multiple objects
to multiple clients; an in-process component can supply multiple objects
to the client and to any other components in its process.
GlobalMultiUse:
is like MultiUse, with one addition: properties and methods of
the class can be invoked as if they were simply global functions. Its
not necessary to explicitly create an instance of the class first,
because one will automatically be created.

SingleUse:
allows other applications to create objects from the class,
but every object of this class that a client creates starts a new
instance of your component. Not allowed in ActiveX DLL projects.

GlobalSingleUse:
is like SingleUse, except that properties and methods of the
class can be invoked as if they were simply global functions.
Not allowed in ActiveX DLL projects.

60 What is ActiveX Dll and ActiveX Exe?
ActiveX DLL:
is a code component that runs in the same process as the
client application. So it runs in the same address space as the client
application that is using the component. Any components you create to
work with Microsoft Transaction Server must be ActiveX DLL components.
Any other components you develop for use on the same machine as the client
application can also be ActiveX DLL components.
This is normally the preferred choice because it is easier to
test (by adding another project using the new VB5 project group feature)
and has better performance.
ActiveX EXE:
is a code component that runs in a separate process from
the client application. So it runs in its own address space.
If you plan to place the component on a computer different
from the computer running the client application and you don't plan
to use Microsoft Transaction Server, the component must be an ActiveX EXE.
ActiveX EXEs are also useful for creating components that can also be
run stand-alone, that is they can be run by clicking on the icon.
This is similar to Excel: you can click on the Excel icon and launch Excel
or you can create an Excel object from VB.
Since ActiveX DLLs are easier to test, you can test your ActiveX EXE
first as an ActiveX DLL and then convert it to an ActiveX EXE using the Project
Properties dialog box
61 Write the steps in Creating ActiveX Dll and Active Exe?
a) Determine the features that the component will provide.
b) Determine what object are required to divide the functionality of the
component in a logical fashion.
c) Design any forms that the component will display.
d) Design the interface-that is, the properties, methods and events-for each
class provided by the component.
e) Implement the forms required by your component.
f) Implement the interface of each class
g) create a project group consisting of the component project and a test project.
i) Compile the DLL and test it with all potential target application.

62) Explain about ActiveX document?
ActiveX Documents offer a way of using VB to add new features to Web Sites.
Anything you can do with VB, you can perform on your web site. ActiveX
supports most standard VB functions and methods, while adding a few new ones,
like Hyperlink. ActiveX Documents is the VB version of JAVA, allowing for
dynamic uses of HTML files, with very little knowledge of the Internet, that
HTML or JAVA requires for the same features.
ActiveX doesn't come without it's costs, but cab files, or Internet
download files, take care of the distribution work for you. Unlike standard VB
projects, you'll have to know the Classid of the Document in order to use it,
but I'll cover how to get the id from the Registry.
In order for ActiveX to really be effective, you'll have to plan you're
ActiveX control just like any program, and just like a normal program, a poorly
designed ActiveX control can really affect how people view your work.
You'll notice the example I used here could be done with standard HTML
and the Command Button OCX, but I kept is simple so the code won't get in the
way of how easy it really is to use ActiveX. You can use the ActiveX Document
at the left to navigate this tutorial, and use it to download the Project
Source and Compiled files, as-well-as a version of this Tutorial for
off-line reading
63 How do I register a component?
run this command " regsvr32 c:\…\MyDll.dll " to register
run this command " regsvr32 \u c:\…\MyDll.dll " to un-register
64 What is OLEDB? What are the important components of OLEDB?
OLEDB is a low-level programming interface designed to access a wide variety
of data sources.
It can support both relational and nonrelational data sources, including
messaging, file system and other non-tradional data sources.
OLEDB specifies set of Component Object Model(COM) interfaces that are used
hide the implementation details required for building data access services.

hat type of databases you can access through ADO?
Spread Sheet, E-Mail, Files, ODBC-Database
66 How many objects resides in ADO ?
a. CONNECTION
b. RECORDSET
c. COMMAND
d. FIELD
e. PARAMETER
f. PROPERTY
g. ERROR
67 What is the use of Connection object?
This object represents a single session wtih the selected data source.
This is quivalent to the type of connection a Data Control makes directly
to the database.
This object can be shared throughout an entire instanance of
an applicaton.
68 Wat is the use of command Object?
This object specifies the data definition or data manipulation
statement to be executed.
69 Recordset object consists what?
Properties and Fields
70 What is the use of parameters collection?
These are part of Command object and allow you to fill in the vaules in the query.
We can take the advantage of database's precompiling of your Query.
This improves speed and efficiency.
71 What are the locks available in Visual Basic?
Locking is the process by which a DBMS restricts access to a row in a
multi-user environment 4 types of locks. They are
adLockReadOnly (Default):
Read-only - users cannot alter the data.
adLockPessimistic:
Pessimistic locking, record by record - the provider does what
is necessary to ensure successful editing of the records, usually
by locking records at the data source immediately upon editing.
adLockOptimistic:
Optimistic locking, record by record - the provider uses optimistic
locking, locking records only when the Update method is called.
adLockBatchOptimistic:
Optimistic batch updates - required for batch update mode as opposed to immediate update mode.
72 What type of recordsets(Cursors) are available in ADO?
adOpenDynamic:
Opens a dynamic-type cursor - allows one to view additions, changes, and deletions by other users, and allows all types of movement through the Recordset.
adOpenKeyset:
Opens a keyset-type cursor - behaves like a dynamic cursor, except that it prevents one from seeing records that other users a and prevents access to records that other users delete. Data changes by other users will still be visible.
adOpenStatic:
Opens a static type cursor - provides a static copy of a set of records to find data or generate reports. Additions, changes, or deletions by other users will not be visible.
adOpenForwardOnly(Default):
Opens a forward-only cursor - behaves identically to a static cursor except that it allows to scroll forward only through records. This improves performance in situations where you need to make only a single pass through a Recordset.
73 What is the use of ON ERROR GOTO 0?
To turn off error trapping.
ie)Disables any active error handling. Any errors cause the basic VB
error message box to be displayed and then the program to be terminated.
This is the default setting.
74 What are Stored Procedures?
SPs are an advanced feature in SQL server that offers you to create,
compile and run SQL statements in the server itself, to isolate your business
logic from data logic and to improve the performance of your application.
In short, write SQL queries in a specific format in the SQL server
and call them from your application, instead of writing queries inside your
program code.
75 Why write Stored procedures?
a. Mainly to increase the performance and the momentum to our programs. When you write a stored procedure, it will be pre-compiled by the SQL server, so that it can increase the speed of executing the queries and hence your
application. When you write a stored procedure the database(DB) server
automatically generates an execution plan for the procedure. The plan will
be updated whenever a change is made in the procedure by the DB server.
b.You can take away all your SQL commands so that the data logic can be
isolated from your business logic(ie.,Coding). This kind of encapsulation
helps the web server to read and interpret lengthy and complex SQL commands.
c.Then like COM, stored procedures can be reused. For example if you want to do the same query in two different ASP pages or in VB forms, you can
reuse the stored procedure which you have written for one page, It saves you time.
d.The application code as well as the stored procedure code are becoming easy to maintain. Updating a stored procedure may not affect the other part of an application or user who uses the same stored procedure.
e.The queries can be customized by using input/output parameters, like functions and procedures which you write in your programming languages

76 What are the types of Stored Procedures?
There are three types of stored procedures. Microsoft supplies several stored procedures to manipulate and administrate the database.
Apart from them can write custom stored procedure to use them in our application level.
1. System stored procedures:
System stored procedures are mainly used for administrating, assisting, configuring and monitoring the SQL server.
2. Extended stored procedures:
Extended stored procedures are used to access SQL server by using dlls.We can use C or C++ to write extended stored procedures with Dlls. One good example is accessing the operating system commands on SQL server. We can use a stored procedure called xp_cmdshell to to run a DOS command, like the following one.
xp_cmdshell "dir c:\",
will list the files in the root directory of C drive.
3. Custom stored procedures:
These are the stored procedures we write. There are several advantages in writing our own stored procedures. We are able to write complex and nested statements with less effort. In this article we focus only on custom stored procedures, in the following section. Where to write
78 Calling Stored Procedures in VB?
Call stored procedure from visual basic
=======================================
This is a simple stored procedure call for testing.
See the database access layer for a better solution
Dim sServer As String
Dim sUser As String
Dim sPWD As String
Dim sDatabase As String
Dim DBcon As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objparameter As New ADODB.Parameter
Dim objRs As New ADODB.Recordset
sServer = "(local)"
sDatabase = "mydb"
sUser = "sa"
sPWD = "password"
DBcon.ConnectionString = "Provider=sqloledb;" & _
"server=" & sServer & ";uid=" & sUser & ";pwd=" & sPWD & ";database=" & sDatabase
DBcon.CursorLocation = adUseClient
DBcon.Open
objparameter.Direction = adParamInput
objparameter.Type = adVarChar
objparameter.Size = 5
objparameter.Value = "hello"
objCmd.Parameters.Append objparameter
objCmd.ActiveConnection = DBcon
objCmd.CommandType = adCmdStoredProc
objCmd.CommandText = "s_mysp"
Set objRs = objCmd.Execute ' objCmd.Execute for no resultsetS
set objRs.ActiveConnection = Nothing
Set objCmd = Nothing
DBcon.Close
79 What do you mean by provider?
Data Provider make a particular type of data available. For instance,
there are currently providers available for ODBC, Microsoft SQL server(Microsoft Enterprice database system) and index server, and more are on the way. These providers know how to retrieve data from a particular data sourceand how to make it available within the Universal Data Access framenetwork.
80 Is it possible to call oracle database through ADO control or Object?
Yes.
Conn.ConnectionString="Provider=MSDAORA.1;" & _
"Driver=MicroSoft ODBC for ORACLE;" & _
"Server=Server_Name;" & _
"Uid=SCOTT;" & _
"PWD=TIGER"
Conn.Open

No comments: