borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Web Browser control)Next Topic (VB Current Directory (in IDE)) New Topic New Poll Post Reply
AndreaVB Forum : Frequently Asked Questions : ADO Connection
Poster Message
chintu4u
Level: Graduate

Registered: 22-03-2006
Posts: 11

icon ADO Connection

Hi all,
        I m new to programming plz help me. I want to know how many different ways are there for Database connection with help of ADO.

Are they diferent types for connection?
1)Connection string.
2)ODBC..
3)DSN
4)DSn-Less

I dont no any thing regarding it so plz help me for the same.

22-03-2006 at 08:57 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: ADO Connection

ODBC: short of Open Database Connectivity. It provides a standard set of API functions that you can use to access a wide range of data sources. YOu can think of it as a layer, to which you pass a command, and this layer translates the command requested to the native syntax, and returns the results to your application. However, ODBC API is complex to work with. In Windows OS, an ODBC control panel is available to manage ODBC connections.

OLE DB: short of Object Linking and Embedding for Databases.  It is a successor to ODBC and consist of API that allow you access to universal data sources using a Component Object Model (COM). It ptovides all the capabilities of ODBC but is divided into two components: 1) consumers - who use the data, and 2) providers  - who works with data and expose an interface to the consumers. It's the core of Microsoft's database technology today. Only C++ applications originally had direct access to OLE DB.

ADO: short of ActiveX Data Objects. It is a wrapper around OLE DB and is made to hide the complicated syntax of OLE DB. ADO provides all the capabilities of OLE DB.

examples of ADO and OleDB and ODBC connection strings:

OLEDB Connection String for Access database (recommended)
"Provider=Microsoft.Jet.OLEDB.4.0;Data SourceathToDatabase;"


ODBC Connection String for Access database (not recommended)
"Driver={Microsoft Access Driver (*.mdb)};dbqathToDatabase;"


DSN: short of Data Source Name. Basically, it is a pointer to a System Data Source you set up in the ODBC manager.

DSN-less: It is a connection string that specifies everything that the system needs to know whenc onnecting to a data source. A DSN-less connection string is usually preferred as it's much more portable than a DSN conn string.

____________________________
If you find the answer helpful, please mark this topic as solved.

22-03-2006 at 11:36 AM
View Profile Send Email to User Show All Posts | Quote Reply
chintu4u
Level: Graduate

Registered: 22-03-2006
Posts: 11
icon Re: ADO Connection

Thank you for reply Mr. Goran .
But can you give more clear idea regarding it and
what is the difference between ADODC and ADODB.
Give me some full examples for it..
Thank you in advance..

23-03-2006 at 12:51 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: ADO Connection

I believe the best think to do is read some begginers book about ADO. Answers to a few questions will only open a 1000 more. From the questions you are asking, I see that you dont know nothing about ADO (you did said that you are a begginer), so you wont learn much about ADO this way, and this approach will only keep you more confused.
So, find a ebook on a net, and spend a day or two reading it, and all will be much clearer.

____________________________
If you find the answer helpful, please mark this topic as solved.

23-03-2006 at 02:33 PM
View Profile Send Email to User Show All Posts | Quote Reply
chintu4u
Level: Graduate

Registered: 22-03-2006
Posts: 11
icon Re: ADO Connection

Mr. Goran, as you say I gone through some website and now I got idea regarding ADO.Now can u help me for the cursor types and Lock types. Good u give easy reference to understand it..

30-03-2006 at 12:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: ADO Connection

There where many excellent articles on net about cursors, but seems that all of them are charging to read them. Let me try to explain in short:

Cursor: It is something that is used for record navigation (move to previous/next record), to update data, and to allow you to see changes made to data by other users.... in simpler form, when you return data in a recordset, it allows oyu to browse data and to know the current position in a recordset you are browsing.

Cursor type

There are 4 types of cursors: adOpenDynamic, adOpenKeyset, adOpenStatic and adOpenForwardOnly.

When we talk about cursor type, we talk about what type of movement is allowed - ex whether we can make to move backward to recordset or only forward, whether we can return the number of records (RecordCount property). Cursor type also determines whether we can see the changes to data made by other users.

All this functionalities can be but doesnt need to be supported by one cursor. The reason for this is because a cursor carries with it some overheat when used, which affects application performance. The more functionallity it supports, the more overheat it carries. Lets say that you need to return some data in a recordset, and you need to determine which cursor type you will use. If data is only for displaying (read-only data), then our choice should be forward only cursor, not dynamic cursor. The difference in speed executinn will be quite big.

adOpenDynamic cursor
It carries the biggest overheat. It 'notifies' us (allow us to see) about added, changed and deleted records by other users, and allows all types of movement through the recordset.

adOpenKeyset cursor
Similar to dynamic cursor, except that it only allow us to see the changes to records made by other users. It doesnt inform us about added or deleted records by other users. It also allows all types of movement through the recordset.

adOpenStatic cursor
This cursor doesnt allow us to see changes to records by other users, nor does it notify us about added/delteted records. For this reason, it carries much less overheat that the 2 cursors above. As dynamic and keyset cursors, It providesss all types of movement through the records.

adOpenForwardOnly cursor
Default cursor. It is identical to a static cursor except that you can only move forward through records. This will improve performance when you only need to loop through data.


LockType

This type tells the provider (we communicate with provider when we want to do something with data) how records should be locked when we are changing data. Locking data can prevent one user from reading data (or changing data) that is being changed by another user.

There are 4 types of locks: adLockOptimistic, adLockPessimistic, adLockReadOnly and adLockBatchOptimistic.

adLockOptimistic lock type
With this type of locking, records are locked only when Update method is called.

adLockPessimistic lock type
This locks record immediately after the record is edited. This ensures succesfull editing.

adLockReadOnly lock type
Default lock. This type of lock doesnt allow data editing. This lock type is used when we want to only display data, and is extremely fast.

adLockBatchOptimistic lock type
This type of lock is usually used with with disconnected recordsets. These recordsets are updated locally and all modifications are sent back to the database in a batch.

[Edited by Goran on 31-03-2006 at 12:17 PM GMT]

____________________________
If you find the answer helpful, please mark this topic as solved.

31-03-2006 at 11:15 AM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: ADO Connection

Goran,
Explicit and clear. I suggest we promote this to FAQ.
Thoughts?
K


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

31-03-2006 at 10:26 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Frequently Asked Questions : ADO Connection
Previous Topic (Web Browser control)Next Topic (VB Current Directory (in IDE)) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder