CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    OLEDB and ODBC ?

    Hi !!

    Can some one tell me, Whats the Difference between OLEDB and ODBC ?
    Why OLEDB is teated as Superier ?
    I want to use OLEDB to connect to Oracle, without using ODBC.
    What syntax should i use ?

    Case:
    Suppose the Username is Vipul
    Suppose the Password is Passw
    Suppose the Tablename is AllBills

    Please Provide code, To Connect to Oracle using OLEDB and Do a "Select * .."
    on the Indicated Table ......

    This will make me understand more exactly.

    Thanks a Lot.




    PS: I work with Win32 API Programming, and not with MFC.

    -Vipul Pathak.
    Indore, (MP) INDIA.
    ICQ# 102045224

    If this Helps: Please Rate .... :-)
    (*Vipul)() ;

  2. #2
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    78

    Re: OLEDB and ODBC ?

    From MSDN


    public Sub ConnectionStringX()

    Dim cnn1 as ADODB.Connection
    Dim cnn2 as ADODB.Connection
    Dim cnn3 as ADODB.Connection
    Dim cnn4 as ADODB.Connection

    ' Open a connection without using a Data Source Name (DSN).
    set cnn1 = new ADODB.Connection
    cnn1.ConnectionString = "driver={SQL Server};" & _
    "server=bigsmile;uid=sa;pwd=pwd;database=pubs"
    cnn1.ConnectionTimeout = 30
    cnn1.Open

    ' Open a connection using a DSN and ODBC tags.
    set cnn2 = new ADODB.Connection
    cnn2.ConnectionString = "DSN=Pubs;UID=sa;PWD=pwd;"
    cnn2.Open

    ' Open a connection using a DSN and OLE DB tags.
    set cnn3 = new ADODB.Connection
    cnn3.ConnectionString = "Data Source=Pubs;User ID=sa;Password=pwd;"
    cnn3.Open

    ' Open a connection using a DSN and individual
    ' arguments instead of a connection string.
    set cnn4 = new ADODB.Connection
    cnn4.Open "Pubs", "sa", "pwd"

    ' Display the state of the connections.
    MsgBox "cnn1 state: " & GetState(cnn1.State) & vbCr & _
    "cnn2 state: " & GetState(cnn2.State) & vbCr & _
    "cnn3 state: " & GetState(cnn3.State) & vbCr & _
    "cnn4 state: " & GetState(cnn4.State)

    cnn4.Close
    cnn3.Close
    cnn2.Close
    cnn1.Close

    End Sub




    Also,


    public Sub ProviderX()

    Dim cnn1 as ADODB.Connection
    Dim cnn2 as ADODB.Connection
    Dim cnn3 as ADODB.Connection

    ' Open a connection using the Microsoft ODBC provider.
    set cnn1 = new ADODB.Connection
    cnn1.ConnectionString = "driver={SQL Server};" & _
    "server=bigsmile;uid=sa;pwd=pwd"
    cnn1.Open strCnn
    cnn1.DefaultDatabase = "pubs"

    ' Display the provider.
    MsgBox "Cnn1 provider: " & cnn1.Provider

    ' Open a connection using the Microsoft Jet provider.
    set cnn2 = new ADODB.Connection
    cnn2.Provider = "Microsoft.Jet.OLEDB.3.51"
    cnn2.Open "C:\Samples\northwind.mdb", "admin", ""

    ' Display the provider.
    MsgBox "Cnn2 provider: " & cnn2.Provider

    ' Open a connection using the Microsoft SQL Server provider.
    set cnn3 = new ADODB.Connection
    cnn3.Provider = "sqloledb"
    cnn3.Open "Data Source=srv;Initial Catalog=pubs;", "sa", ""

    ' Display the provider.
    MsgBox "Cnn3 provider: " & cnn3.Provider

    cnn1.Close
    cnn2.Close
    cnn3.Close

    End Sub




    And...

    "The Microsoft OLE DB Provider for Oracle allows ADO to access Oracle databases.

    Connection String Parameters

    To connect to this provider, set the Provider argument to the ConnectionString property to: MSDAORA "

    Check out the MSDN library for lots more info. and examples.... hope it gets you started.

    RF




  3. #3
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    Re: OLEDB and ODBC ?

    thats fine. Thanks !!

    But, what about the first part of my Question ?
    Whats the difference between these two ?




    PS: I work with Win32 API Programming, and not with MFC.

    -Vipul Pathak.
    Indore, (MP) INDIA.
    ICQ# 102045224

    If this Helps: Please Rate .... :-)
    (*Vipul)() ;

  4. #4
    Join Date
    Apr 2000
    Posts
    737

    Re: OLEDB and ODBC ?

    OLEDB is newer than ODBC, and indeed they are not the same.

    ODBC is a standard for accessing data, with a common set of APIs the programmer must use in order to access data. However, this only apply to database, but what about if someone want to store other thing, like spreadsheet, email, etc ??
    So, OLE-DB is microsoft UDB strategy to access the data contained in any kind of data store.

    I am not sure, a magazine said that OLD-DB is faster & might well replace ODBC in the future.

    Actually, both of the also let the programmer to work with a common set of APIs, just OLE-DB allows access to much broader range of data, in fact OLE-DB supports database connection through ODBC.

    Last, ADO is the COM wrapper of OLE-DB cause scripting language can only talk with OLE-DB via ADO.

    P.S. sometime I also feel working with API is better than MFC, but not always.


    HTH

    cksiow
    http://vblib.virtualave.net - share our codes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured