VB.Net - connecting to Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • booner

    VB.Net - connecting to Access

    I've been using OdbcConnection, OdbcCommand, etc to do work associated with
    an Access 2003 database - is that the best? What are the other
    alternatives - and their pros/cons?

    Any/all insights - much appreciated.

    BBB


  • tommaso.gastaldi@uniroma1.it

    #2
    Re: VB.Net - connecting to Access

    On 6 Giu, 15:25, "booner" <b3boo...@yahoo .comwrote:
    I've been using OdbcConnection, OdbcCommand, etc to do work associated with
    an Access 2003 database - is that the best? What are the other
    alternatives - and their pros/cons?
    >
    Any/all insights - much appreciated.
    >
    BBB
    hi BBB,

    I have been using the OleDB connection and works fine and fast.
    Let me know if you need more info about that.


    Tommaso
    -- Datatime Universal (free) http://cam70.sta.uniroma1.it/DatatimeUniversal/
    --

    Comment

    • booner

      #3
      Re: VB.Net - connecting to Access

      I've got ODBC connection working.

      I guess I was looking for a breakdown of why I would use (pros/cons) Odbc or
      OleDb, Sql, Ado ...

      Just trying to educate myself on the options and when/why to use them.


      "tommaso.gastal di@uniroma1.it" <Tommaso.Gastal di@gmail.comwro te in message
      news:1181139253 .960359.84200@q 75g2000hsh.goog legroups.com...
      On 6 Giu, 15:25, "booner" <b3boo...@yahoo .comwrote:
      >I've been using OdbcConnection, OdbcCommand, etc to do work associated
      >with
      >an Access 2003 database - is that the best? What are the other
      >alternatives - and their pros/cons?
      >>
      >Any/all insights - much appreciated.
      >>
      >BBB
      >
      hi BBB,
      >
      I have been using the OleDB connection and works fine and fast.
      Let me know if you need more info about that.
      >
      >
      Tommaso
      -- Datatime Universal (free)

      --
      >

      Comment

      • Rich P

        #4
        Re: VB.Net - connecting to Access

        You definitely want to use the OleDB connection because that allows you
        to use the OleDBDataAdapte r which is the BEST way to move data to and
        from any OleDB database. The DataAdapter (OleDBDataAdapt er,
        SqlDataAdapter) forgo having to loop through data. You can use the Fill
        method to retrieve data into a .Net Dataset in one shot and you can use
        the Update Method to Insert and Update Data on the Database side.

        The DataAdapter has revolutionized how you Read/Write data From/To any
        RDBMS

        Rich

        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • tommaso.gastaldi@uniroma1.it

          #5
          Re: VB.Net - connecting to Access

          On 6 Giu, 17:26, Rich P <rpng...@aol.co mwrote:
          You definitely want to use the OleDB connection because that allows you
          to use the OleDBDataAdapte r which is the BEST way to move data to and
          from any OleDB database. The DataAdapter (OleDBDataAdapt er,
          SqlDataAdapter) forgo having to loop through data. You can use the Fill
          method to retrieve data into a .Net Dataset in one shot and you can use
          the Update Method to Insert and Update Data on the Database side.
          >
          The DataAdapter has revolutionized how you Read/Write data From/To any
          RDBMS
          >
          Rich
          >
          *** Sent via Developersdexht tp://www.developersd ex.com***
          I agree with Rich about the OleDb Connection. Oledb is the way to go
          now.

          But, if I may, I would not recommend too much the OleDBDataAdapte r. In
          my opinion,
          in most situations one could even disregard its existence and focus on
          the OleDbDataReader
          directly (which is anyway used by the adapter), because more general
          and flexible.

          Another big advantage is given by the OleDbSchemaGuid which makes
          possible
          easy integration among platforms and metadata retrieval.


          Tommaso
          -- Datatime Universal (free) http://cam70.sta.uniroma1.it/DatatimeUniversal/


          Comment

          • booner

            #6
            Re: VB.Net - connecting to Access

            What advantages do I get by using the OleDB classes (Connection, Command)
            versus their Odbc counterparts?

            From what I can see - other than connection string used - the general means
            for doing db work - is nearly identical.

            So why use Ole vs. Odbc vs. ADO ... set of classes?

            I have the general mechanics down - just not sure which set of classes get
            me the most bang for the buck.

            "tommaso.gastal di@uniroma1.it" <Tommaso.Gastal di@gmail.comwro te in message
            news:1181145375 .749924.223310@ q69g2000hsb.goo glegroups.com.. .
            On 6 Giu, 17:26, Rich P <rpng...@aol.co mwrote:
            >You definitely want to use the OleDB connection because that allows you
            >to use the OleDBDataAdapte r which is the BEST way to move data to and
            >from any OleDB database. The DataAdapter (OleDBDataAdapt er,
            >SqlDataAdapter ) forgo having to loop through data. You can use the Fill
            >method to retrieve data into a .Net Dataset in one shot and you can use
            >the Update Method to Insert and Update Data on the Database side.
            >>
            >The DataAdapter has revolutionized how you Read/Write data From/To any
            >RDBMS
            >>
            >Rich
            >>
            >*** Sent via Developersdexht tp://www.developersd ex.com***
            >
            I agree with Rich about the OleDb Connection. Oledb is the way to go
            now.
            >
            But, if I may, I would not recommend too much the OleDBDataAdapte r. In
            my opinion,
            in most situations one could even disregard its existence and focus on
            the OleDbDataReader
            directly (which is anyway used by the adapter), because more general
            and flexible.
            >
            Another big advantage is given by the OleDbSchemaGuid which makes
            possible
            easy integration among platforms and metadata retrieval.
            >
            >
            Tommaso
            -- Datatime Universal (free)

            >
            >

            Comment

            • Rich P

              #7
              Re: VB.Net - connecting to Access

              Here is a quicky sample of the OleDB class used with an Access mdb

              Imports System.Data.Ole Db
              Imports System.Data

              Public Class Form7
              Dim conn As OleDbConnection , da As OleDbDataAdapte r
              Dim ds As DataSet, curMgr As CurrencyManager

              Private Sub Form7_Load(ByVa l sender As System.Object, ByVal e As
              System.EventArg s) Handles MyBase.Load
              conn = New OleDbConnection
              conn.Connection String = "provider=micro soft.jet.oledb. 4.0; Data Source =
              C:\Code\testAcc \db2test.mdb"
              da = New OleDbDataAdapte r
              ds = New DataSet
              da.SelectComman d = New OleDbCommand
              da.SelectComman d.Connection = conn
              da.SelectComman d.CommandType = CommandType.Tex t
              da.SelectComman d.CommandText = "Select * from Table1"
              da.Fill(ds, "tbl1")
              curMgr = CType(Me.Bindin gContext(ds.Tab les("tbl1")), CurrencyManager )
              curMgr.Position = 0
              tssL3.Text = curMgr.Count.To String
              tssL2.Text = (curMgr.Positio n + 1).ToString
              dgrv1.DataSourc e = ds.Tables(0)
              End Sub

              Private Sub dgrv1_Click(ByV al sender As Object, ByVal e As
              System.EventArg s) Handles dgrv1.Click
              '--this will display the number of the record you are on
              '--in the Datagridview - same as a table or query in Acc
              tssL2.Text = (curMgr.Positio n + 1).ToString
              End Sub
              End Class

              Note: tssL2 and tssL3 are labels on a statusStrip (my naming
              convention). The statusStrip is the control that replaces the StatusBar
              - much more horsepower. dgrv1 is a DatagridView control (the equivalent
              of a subform, but way more horsepower and flexibility).

              You could use the OleDBDataReader or DataAdapter. The OleDBDataReader
              doesn't have the Fill method, but if you don't need to fill a table to
              view in a DatagridView control, then the Reader is probably more
              efficient.

              This sample may not look like much, but if you apply it to a large
              project, you will end up writing way less code using the OleDB class
              than the ODBC class. THe ODBC class is mostly for legacy stuff, like
              for DBF tables. Access is an OleDB application, so you should take
              advantage of the improvements OleDB offers over ODBC.

              Rich

              *** Sent via Developersdex http://www.developersdex.com ***

              Comment

              • tommaso.gastaldi@uniroma1.it

                #8
                Re: VB.Net - connecting to Access

                On 6 Giu, 20:07, "booner" <b3boo...@yahoo .comwrote:
                What advantages do I get by using the OleDB classes (Connection, Command)
                versus their Odbc counterparts?
                >
                From what I can see - other than connection string used - the general means
                for doing db work - is nearly identical.
                >
                So why use Ole vs. Odbc vs. ADO ... set of classes?
                >
                I have the general mechanics down - just not sure which set of classes get
                me the most bang for the buck.
                >
                You may also want to take a look ar these.

                eSports News, Results, upcoming Matches & live Matches. Learn tricks and guides in the esports space. ✅ We cover CS:GO, Dota 2, LOL, Overwatch & PUBG. 

                eSports News, Results, upcoming Matches & live Matches. Learn tricks and guides in the esports space. ✅ We cover CS:GO, Dota 2, LOL, Overwatch & PUBG. 




                In any case switching to oledb you will experience advantages,
                especially
                if you ever need to write (general) code to be used against different
                dbms

                [to me, for programming purposes, the decisive argument is the
                oledbschemaguid :
                I would use it even if it performed slower, just because of the
                metadata available]

                T



                Comment

                • booner

                  #9
                  Re: VB.Net - connecting to Access

                  Thanks.

                  They threw me off by calling it OLE - clearly, with .net - not my father's
                  OLE (from back in the day).

                  "tommaso.gastal di@uniroma1.it" <Tommaso.Gastal di@gmail.comwro te in message
                  news:1181158088 .389657.52820@g 37g2000prf.goog legroups.com...
                  On 6 Giu, 20:07, "booner" <b3boo...@yahoo .comwrote:
                  >What advantages do I get by using the OleDB classes (Connection, Command)
                  >versus their Odbc counterparts?
                  >>
                  >From what I can see - other than connection string used - the general
                  >means
                  >for doing db work - is nearly identical.
                  >>
                  >So why use Ole vs. Odbc vs. ADO ... set of classes?
                  >>
                  >I have the general mechanics down - just not sure which set of classes
                  >get
                  >me the most bang for the buck.
                  >>
                  >
                  You may also want to take a look ar these.
                  >
                  eSports News, Results, upcoming Matches & live Matches. Learn tricks and guides in the esports space. ✅ We cover CS:GO, Dota 2, LOL, Overwatch & PUBG. 

                  eSports News, Results, upcoming Matches & live Matches. Learn tricks and guides in the esports space. ✅ We cover CS:GO, Dota 2, LOL, Overwatch & PUBG. 

                  >
                  >
                  >
                  In any case switching to oledb you will experience advantages,
                  especially
                  if you ever need to write (general) code to be used against different
                  dbms
                  >
                  [to me, for programming purposes, the decisive argument is the
                  oledbschemaguid :
                  I would use it even if it performed slower, just because of the
                  metadata available]
                  >
                  T
                  >
                  >
                  >

                  Comment

                  Working...