How to use ADO and VBA to Read from a Database

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024

ความคิดเห็น • 104

  • @Excelmacromastery
    @Excelmacromastery  3 ปีที่แล้ว +6

    Let me know what you think of this video in the comments below. Make sure to download the code examples from the description.

    • @thuthaonguyen8424
      @thuthaonguyen8424 3 ปีที่แล้ว

      Thank u so much for your helpful video.
      I have a question which i will be very greatful if getting ur answer for.
      Could ADO connects Bigquery (data source in Google cloud) and excel worksheet? And if yes, please walk me through the codes 🙏🙏🙏

    • @eeius986
      @eeius986 3 ปีที่แล้ว

      Amazing once again Paul, Like ALL your videos! Now using it on my project :).
      What about an Userform to take pictures from the webcam and once image is approved it uploads to a specific cell in Excel? Just an idea for your next video ;)

    • @TheAjayiscool
      @TheAjayiscool ปีที่แล้ว

      Great resource. I am your biggest fan Paul. Facing a bottleneck in my project. Details are in my post. Appreciate any guidance

  • @lalitthapa007
    @lalitthapa007 3 ปีที่แล้ว

    There should be a heart ❤ button in addition to 👍 button.. thank you !!

  • @musabashraf
    @musabashraf ปีที่แล้ว

    Thanks for the video. You cleared many doubts I had.

  • @persaq
    @persaq 2 ปีที่แล้ว

    Perfect! Thank you very much, Paul.

  • @kuaatrichard5806
    @kuaatrichard5806 2 ปีที่แล้ว

    Hello Paul, you make great vodeos. Very good to understand. However, I would also be very happy about a database query from a MySQL database.

  • @big1975E
    @big1975E 2 ปีที่แล้ว

    Awesome video! I’ve used the knowledge I gained from this video multiple times. It has been a real game changer for me! Is it possible to use an ADO connection to connect to a SharePoint online list? SharePoint online seems to be being used more and more. Thanks!!

  • @leeblack2103
    @leeblack2103 3 ปีที่แล้ว +1

    Very Nice! Can you work on a video to work on doing API calls using VBA?

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +1

      It's been on my list for a while now but I hope to do it soon.

  • @Ronaldog2207
    @Ronaldog2207 3 ปีที่แล้ว

    Great Video!!! Congrats!

  • @philipmcdonnell7168
    @philipmcdonnell7168 3 ปีที่แล้ว +2

    My unending work project has to be modded to use Access/SQL Server at some point so this is very timely, Paul. Thanks. Will you be doing a write changes back to the DB and how to 'delete' data in future videos?

  • @ascarrunz
    @ascarrunz 3 ปีที่แล้ว +2

    Paul, awesome video. Thanks a lot for you tips.
    But Could you do video of what is faster: ADO+VBA or PowerQuerry?

  • @rajsurendra7040
    @rajsurendra7040 ปีที่แล้ว

    How to import to a template with discrete columns and rows or mapping the data to specific filed

  • @carlosfinholdt4190
    @carlosfinholdt4190 3 ปีที่แล้ว

    Great job. Thanks.

  • @engrvarsi3774
    @engrvarsi3774 3 ปีที่แล้ว

    Many thanks

  • @danielmadariagavaldes893
    @danielmadariagavaldes893 3 ปีที่แล้ว +3

    I already knew most of these stuff, but man, what a brilliant explanation!!!!!! Marvelous job!!

  • @kuldar.
    @kuldar. 3 ปีที่แล้ว

    Interesting, but next level...

  • @big1975E
    @big1975E 3 ปีที่แล้ว

    If I’m connecting connecting to an Excel workbook with ADO is it possible to edit data in that workbook in addition to querying data from that workbook?

  • @gavdownes100
    @gavdownes100 3 ปีที่แล้ว

    This works great, thanks. Question: How do you use JOIN/ INNER JOIN with regards to Junction tables? I cannot find any tutorials online. To clarify what I am trying to learn, my junction table has a client_ID and product_ID linking to tables Clients and Products. How do I retrieve the Junction table as Clients.name and Products.name

    • @nealonions7654
      @nealonions7654 3 ปีที่แล้ว

      First give your ‘junction table a name, say tblClientProduct. Along with that let’s have tblClient and tblProduct
      Could try
      SELECT
      p.product_name
      , c.customer_name
      FROM
      tblClientProduct AS cp
      INNER JOIN tblClient AS c ON
      cp.client_id = c.client_id
      INNER JOIN tblProduct AS p ON
      cp.product_id = p.product_id

    • @gavdownes100
      @gavdownes100 3 ปีที่แล้ว

      @@nealonions7654 hmmm. Thank you. Will look at that very closely soon

  • @granadosvm
    @granadosvm 3 ปีที่แล้ว +1

    It might be a good idea listing a site or page where the standard SQL syntax code could be explored. For people who are new to this to understand the power of these connections, it would be good to know the potential of SQL code. When you pass parameters from user's input (they could be cells in a sheet) these type of code can be used to create very useful and flexible dashboards.

  • @victorgarmin2311
    @victorgarmin2311 7 หลายเดือนก่อน

    Thanks for sharing, nice video, do you have an example of the conexion string for a oracle database??

  • @SimpleExcelVBA
    @SimpleExcelVBA 3 ปีที่แล้ว

    I haven't yet used this for actual databases, only for Excel worksheet. Need to try with that. Good video :)

  • @karvannansa8045
    @karvannansa8045 ปีที่แล้ว

    How to add custom column with sequence? Sir?

  • @TheAjayiscool
    @TheAjayiscool ปีที่แล้ว

    Awesome video Paul. I have implemented late binding and close connection the way you explained in a project with MS Access as backend. Back end is deployed in a shared drive to which my users have read/ write permission. There are action queries in the project using SQL INSERT and UPDATE also SELECT for reading data into a recordset.
    So far so good. Tool works like charm!
    However on a stress test with 40 + users simultaneously using tool, saw error saying "The database has been placed in a state by user 'Admin' on Machine that prevents it from being opened or locked"
    This some times keeps the backend in exclusive mode and at times corrupts the database.
    Paul, where am going wrong. Any help will be greatly appreciated
    Ajay

  • @officetricks6303
    @officetricks6303 2 ปีที่แล้ว

    Thanks a lot, learned a very simple way to solve complex data, keep posting...

  • @JStruthers89
    @JStruthers89 2 ปีที่แล้ว

    Hi Paul, I was wondering if it is possible to pass a sharepoint list directly to the Named Manager, instead of printing it to a worksheet with ListObject? Thanks in advance

  • @TheDinga1977
    @TheDinga1977 ปีที่แล้ว

    I want to use ADO to get data from an access database that is password protected and the database is stored on a network drive with a specific userid and password instead of the active windows userid. I have searched the web and tried many connection strings…can someone point me in the right direction?

    • @TheDinga1977
      @TheDinga1977 ปีที่แล้ว

      I also want the data to be put in an array to be used in the vba not put into a sheet.

  • @kamalam29
    @kamalam29 3 ปีที่แล้ว

    Hi Paul. Thanks a lot for this video. Although the best part of this tutorial is "How to close the connection correctly" which is very important for big professional projects. Cleaning the objects before the cursor leaves procedure or a function, is a very very delicate and yet complex thing to understand and I think every professional should have an idea of that. it would be great if you can create a tutorial just explaining the different ways to cleaning the objects like acrobat objects, excel objects, word objects, so objects, etc, etc.

  • @muhannad_youssef
    @muhannad_youssef 3 ปีที่แล้ว

    Thank you sir ... how i can find last purchase price from table ( date - product - price - purchase or sales )

  • @zakimoustapha7296
    @zakimoustapha7296 2 ปีที่แล้ว

    Is it possible to create a crystal report from excel workbook? If yes then I think it's an important topic to talk about Teacher.

  • @tigranhayrapetyan8357
    @tigranhayrapetyan8357 2 ปีที่แล้ว

    Very hard for me to understand all of this code, but it's definitely useful thing in job. Will return to it later and make it usable in my everyday work) Thank you Paul for your videos!

  • @javiermolinaperez1671
    @javiermolinaperez1671 2 ปีที่แล้ว

    Really valuable ! I've been searching on the internet for a solution with no chances at all since now ! Many thanks, Late binding seems to work with other computers :)

  • @azul3k
    @azul3k 3 ปีที่แล้ว

    Thanks, I'd like to know how to execute a procedure and how to close the connection.

  • @efraintrejogomez6185
    @efraintrejogomez6185 ปีที่แล้ว

    me sorprende cuanto conocimiento sobre este lenguaje VBA, Saludos cordiales maestro, estoy aprendiendo mucho de usted, a pesar de la barrera del idioma...

  • @lqc1014
    @lqc1014 ปีที่แล้ว

    good skill

  • @3Starsgamer34
    @3Starsgamer34 3 ปีที่แล้ว

    Is ADO still relevant post power query?

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +1

      Of course. There are countless scenarios where PQ wouldn't be suitable. For example, an application that retrieves data to a UserForm based on real-time user selections.

  • @oliveroshea5765
    @oliveroshea5765 3 ปีที่แล้ว

    Hi Paul, could this be achieved by using Office Scripts? I like VBA, but was wondering if Office Scripts offered similar methods.
    Cheers
    Oliver

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +1

      Good question Oliver. At the moment Office Scripts interacts with everything through Power Automate. There may be the possibility to use external libraries in the future but for the moment it's no possible.

  • @serdip
    @serdip 3 ปีที่แล้ว

    Great video. Thanks for posting.
    In addition to looking up standard connection strings, I like to use the DataLinks object as follows:
    Dim objDL As Object
    Dim vntConnection As Variant
    On Error Resume Next
    Set objDL = CreateObject("DataLinks")
    vntConnection = objDL.PromptNew()
    If Err 0 Then
    Err.Clear
    Exit Sub
    End If
    The PromptNew() method will display the Data Link Properties dialog in which the user can specify the Access database, SQL Server database, Excel workbook etc and return the connection string, which does not have to be edited.

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +1

      Thanks for the feeback. I haven't used the DataLink.

  • @hichamhadj9640
    @hichamhadj9640 3 ปีที่แล้ว

    As always, Excellent video !

  • @danilklimov3233
    @danilklimov3233 2 ปีที่แล้ว

    Спасибо

  • @alwilson6471
    @alwilson6471 3 ปีที่แล้ว

    Unable to download the code. The "get the code" option just hangs.....

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว

      Turn off any popup blockers and it should work.

  • @Gg-oh2zy
    @Gg-oh2zy 2 ปีที่แล้ว

    Neat n clean explanations 😀

  • @johnwayne8059
    @johnwayne8059 3 ปีที่แล้ว

    Very good video Paul!👍👍👍
    Btw:
    When I use "exit sub" in sub (e.g. "DoSomething") and then use "DoSomething" in an other sub (e.g. "Main"), I often had the problem that Main also got stopped! Do you've some experience with these "syndrome"? I decided to apply a "goto" to jump over the error handling! Do you think that's a good way?
    B|R from Germany 🤟😎 and thanx in advance!😉

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +1

      Error Handling is tricky when unwinding the code. Check out this video th-cam.com/video/lR5e8gyA69U/w-d-xo.html

    • @johnwayne8059
      @johnwayne8059 3 ปีที่แล้ว

      @@Excelmacromastery okay, thank you, that's also a good explanation! But how can I manage that the Code don't stop. Because I call a sub which is not neccesary for following actions, it's just a nice-to-have in relation to its function! I hope that's a better description what I'msearching for!😇

  • @jimfitch
    @jimfitch 3 ปีที่แล้ว

    Great tutorial, Paul. And perfectly timed - just started a project to extract Access data to Excel workbooks for daily & on-demand status reporting & analysis. Thank you!

  • @govindkumarsodani3290
    @govindkumarsodani3290 ปีที่แล้ว

    very usefull

  • @AlexB_o7
    @AlexB_o7 3 ปีที่แล้ว

    Please do a video on how to store the RS into an array and to operate the data from inside the vector. (index match into the array).

  • @MrKhaldonalali
    @MrKhaldonalali 8 หลายเดือนก่อน

    Excellent video, thank you very much for it

  • @jillianonthehudson1739
    @jillianonthehudson1739 3 ปีที่แล้ว

    This was awesome! Thanks!
    I really don't understand how anyone could downvote content like this

  • @AS-ym2bp
    @AS-ym2bp 3 ปีที่แล้ว

    Can you make a video on how to read and write data from and to an SQL database through VBA?

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +2

      The code for reading from an SQL database is almost the same as the code used here to read from an Access database. The only difference is the connection string. I'll be doing a video, on writing to a database from a worksheet, soon.

  • @kebincui
    @kebincui ปีที่แล้ว

    Mind blowing👍👍. Thanks Paul

  • @alihamiad7849
    @alihamiad7849 3 ปีที่แล้ว

    I never get the source code;
    Am I doing something wrong?

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว

      Send me your email address and I will check it. Paul@ExcelMacroMastery

  • @frikduplessis8849
    @frikduplessis8849 3 ปีที่แล้ว

    Thank you Paul, it has been a long time ⌛ clear explanation on the error handling 👍

  • @mike_case
    @mike_case 3 ปีที่แล้ว

    Great video. Thank you Paul!!!

  • @akdhunt
    @akdhunt 3 ปีที่แล้ว

    Brilliant explanation!
    With late binding is posible to use ADO with Excel for Mac?

    • @nealonions7654
      @nealonions7654 3 ปีที่แล้ว +1

      No unfortunately not. The only (sensible/practical) way I know for Mac is to use ODBC and then use a QueryTable. Then assign the result to a variant. May also need an ODBC drive like the commercial ones from Actual Technologies.

    • @averagebodybuilder
      @averagebodybuilder 3 ปีที่แล้ว

      I actually use late binding for excel.

    • @nealonions7654
      @nealonions7654 3 ปีที่แล้ว

      @@averagebodybuilder What on a Mac not running windows??? As far as I know there is no library to link to and then late bind that runs on OSX?

    • @averagebodybuilder
      @averagebodybuilder 3 ปีที่แล้ว +1

      Oops I didn't read the part where he wrote Mac

  • @VS.R3LeVant
    @VS.R3LeVant 3 ปีที่แล้ว

    Easy to understand thanks for sharing

  • @johnbutler2750
    @johnbutler2750 3 ปีที่แล้ว

    Brilliant stuff! Thanks

  • @kurtisfickle
    @kurtisfickle 3 ปีที่แล้ว

    This is fantastic! Thank you!

  • @vincentlee7995
    @vincentlee7995 3 ปีที่แล้ว

    Thanks Paul.

  • @mtotowamungu8259
    @mtotowamungu8259 3 ปีที่แล้ว

    Thank you Paul

  • @oliveroshea5765
    @oliveroshea5765 3 ปีที่แล้ว

    Thanks Paul!

  • @briandennehy6380
    @briandennehy6380 3 ปีที่แล้ว

    Thank god for Power Query I say 🤣🤣🤣

    • @Excelmacromastery
      @Excelmacromastery  3 ปีที่แล้ว +1

      Hi Brian, do you think the code is too complex?

    • @briandennehy6380
      @briandennehy6380 3 ปีที่แล้ว

      @@Excelmacromastery Hi Paul, for me as someone who is learing VBA, it is a bit advanced. I just love the ease of Power Query to do this sort of thing but it is very well explained in the video

    • @oliveroshea5765
      @oliveroshea5765 3 ปีที่แล้ว

      @@briandennehy6380 it’s no more complex than the M code in the advanced editor in Power Query

    • @briandennehy6380
      @briandennehy6380 3 ปีที่แล้ว

      @@oliveroshea5765 True but with Power Query you can use the GUI to connect to a database without the need to know VBA.

    • @partymaschine92
      @partymaschine92 3 ปีที่แล้ว

      Again another great video of you, but I have to admit that I must totally aggree with Brian. Could you explain the advantage to crawl data via vba? In the video it seems to be faster, but I am not sure. I am comfortable with both kind of codes VBA and M and would love to give both versions a chance, however I love to use PQ in Excel. It is so much easier to pass on the file to colleagues who are not able to run macros due to companies restrictions.