VB.NET Tutorial - Connect & Query a Microsoft SQL Server Database - Part 1

In this VB.NET Database Tutorial, I will show you how to connect and query a Microsoft SQL Server database from your Visual Basic .NET application. We will build an improved connection control class for simplified access to our database.
Additionally, we will create a database search feature with wildcard support and populate a DataGridView and ComboBox with a database query.
SHORTCUTS:
0:25 Preparing the database
15:34 Creating your application
26:35 Building your SQL Control Class
1:06:00 Using the SQL Control Class
1:09:10 Query SQL to a DataGridView
1:16:33 Building a parameterized search with wildcard support
1:24:04 Populate a ComboBox with SQL Query results
1:30:30 Error Testing
PROJECT SOURCE CODE:
www.dropbox.com/s/80025odtkct...
Thank you for your support!

Пікірлер: 239

  • @k1ng50
    @k1ng503 ай бұрын

    Thank you very much for a well-organized, clear tutorial. I did a lot of VB4 programming in the 1990s but none since. I retired a few years ago and wanted to resurrect and continue a project I did back then. This video served as a great refresher and I am ready to continue your series.

  • @fletcherevans830
    @fletcherevans8305 жыл бұрын

    Thank you so much! These DB tutorial videos are super - I've learned a lot. Your content is well laid out and your presentation is excellent.

  • @randysandberg3755
    @randysandberg37557 жыл бұрын

    Hi VBToolbox. Glad to see you active again. I hate moving too--I think most people do. At 66 years old I have done it 20 times so far in my adult life. I followed many of your DB tutorials in the past, and am waiting to see what you will present next. When you fill the combo box you can use a row index like r(0) instead of the column name. No big deal. It's just shorter.

  • @roadie3124
    @roadie31242 жыл бұрын

    Thank you very much for this. It's very useful and I like your laconic style :-) I'm using VS2019. I'm 72 years old, retired, and I'm having fun exercising my mind learning VB.net and Visual Studio. I've been programming off and on since the late 1960s. The off periods were when I was managing mainframe software projects, doing strategic planning and being an IT Director for an insurance company. Programming is more fun. I started with FORTRAN at uni, then went onto Assembler, machine code, COBOL, ALGOL with Burroughs, used Burroughs DMSII, IBM's IMS, Digital's Rdb until I retired from the corporate rat race, bought a copy of Access when it was first released and had to learn VBA. I learned enough VB6 to modify existing systems. I got into SQL Server in 1997 and became an accidental DBA. I had such a lucrative business developing systems with Access front ends to SQL Server that I never got around to learning .net. I became fluent in T-SQL. I've flirted with learning VB.net a few times, but commercial pressured got in the way. I subscribed to an online learning company and didn't get much satisfaction. This tutorial of yours is exactly what I've been looking for to learn VB.net and how to interface with SQL Server. You explain things at the level I need. Thank you very much.

  • @maptrking
    @maptrking4 жыл бұрын

    22:24 - THIS IS the BEST THING I'VE HEARD!!! EXACTLY what I'm trying to do... THANK YOU!!!

  • @Cylon39
    @Cylon397 жыл бұрын

    Your BACK!!! Wonderful videos!!! Thanks for posting them... So helpful.

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    I hope so! Figured I'd best get to it whilst there's a lull in the chaos. :-D

  • @mariusadrianstefan9844
    @mariusadrianstefan9844 Жыл бұрын

    Hi, many thanks for this VB tutorial, by far is the best from what i found on KZread so far and i was looking for a while (few months).

  • @aungyethu9743
    @aungyethu97435 жыл бұрын

    never seen like the way you teach before, thanks a million.... wish you could post more of tutorial videos.....

  • @gyustice665
    @gyustice6657 жыл бұрын

    Thanks for these videos!! I've been using them for my job and they've helped me tons!! you're the best!

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Awesome! I'm very happy that they're helping you out. I'm envious that you get to do this for work. :-D

  • @Kicajz7
    @Kicajz75 жыл бұрын

    You just saved my life :) Thank you!

  • @bernardlogador5364
    @bernardlogador53646 жыл бұрын

    Thanks man, your videos made transitioning from VB6 to .net easy!

  • @chloekimball536
    @chloekimball5365 жыл бұрын

    My good sir, you are a lifesaver. I should browse through your channel. i have a feeling you will become one of my best teachers!

  • @poweroverwhelming1847
    @poweroverwhelming18474 жыл бұрын

    Your tutorials are too good to exist. 10000/10

  • @josepachecou
    @josepachecou7 жыл бұрын

    Very nice tutorial !!! waiting for the next video, hope comes soon. Thanks a lot.

  • @skfunnext
    @skfunnext5 жыл бұрын

    Thanks for such a sweet explanation - really loved this tutorial and started following your series

  • @TheJawtech
    @TheJawtech7 жыл бұрын

    GREAT tutorial, dude you have saved my application. I haven't done much newer VB but was pretty awesome with VB6. I've got my application together but for the life of me cannot get the "built in" stuff to work with the logic I need. I had realized that the default controls were not going to be much help but it's not like you see their code so there is nothing to change. Tableadapters seem to be a nightmare. This sqlcontroller class is EXACTLY what I was missing. JAW

  • @leansixsigmabusinessoperat4833
    @leansixsigmabusinessoperat4833Ай бұрын

    Thank you so much .................................!! You're doing a great help to the generations of learners

  • @lbb5754
    @lbb57546 жыл бұрын

    LOVE it - You are a life saver.

  • @wim2561
    @wim25616 жыл бұрын

    This is great. Have been searching for time to find the right stuff where it is explained well. This did. Thanks just did part one have to go for the other parts. It feels as you sitting beside us and showing. Tanks a lot.

  • @VBToolbox

    @VBToolbox

    6 жыл бұрын

    I'm very happy that the tutorials have been helpful! :-)

  • @prinschoco
    @prinschoco4 жыл бұрын

    Thanks I could simplify my code at work a lot using this SQL control class.

  • @grantharrismusic
    @grantharrismusic2 жыл бұрын

    I've found this video equal parts challenging and rewarding. Rewarding because it has expanded my knowledge about databases and how sql works. Challenging because there are aspects of the coding that are above my self-taught level. To that extent if there is anyone who would be kind enough to show me how to make use of the Over-ride code in very very simple terms I would be extremely grateful. Thank you. UPDATE: I have done some thinking and reading and I re-watched this video and realise that the answer to my question was there all along - I just didn't understand enough to fully recognise it. Thanks for this video - it's been a great catalyst for learning so much new material for someone who started learning Vb by hacking excel macros. Many thanks.

  • @zmareyshahi

    @zmareyshahi

    2 жыл бұрын

    Same Here

  • @giorgosnasenas3290
    @giorgosnasenas32904 жыл бұрын

    Thanks for the tutorials. Great Examples for real work and great for teaching

  • @KhalidAfridi1
    @KhalidAfridi17 жыл бұрын

    Thanks a lot, It's really awesome :) so clean and simple.

  • @ranie4877
    @ranie4877 Жыл бұрын

    THank you I'm newbie and I really appreciated your work here

  • @hassansamara7381
    @hassansamara73815 жыл бұрын

    Thanks for this Simple and reach tutorial.

  • @boundhell3998
    @boundhell39987 жыл бұрын

    dude i love you so much right now, you just saved me from the fucking assignment. thank godness i find you here

  • @arjunkhatiwada5148
    @arjunkhatiwada51484 жыл бұрын

    Really great!, we expect such more other videos, Thanks a lot.

  • @mirkomarkovic1492
    @mirkomarkovic14927 жыл бұрын

    So clean and nice code! This was very helpful, thanks a lot.

  • @ga7853
    @ga78537 жыл бұрын

    Thank you so much for this great tutorial. its as always very helpful and easy to degust thanks to your easy way of explaining things.

  • @erikvandervlugt2139
    @erikvandervlugt21396 жыл бұрын

    Perfectly explained!!!

  • @dougiemui4519
    @dougiemui45196 жыл бұрын

    Welcome back bro. Thumbs up for your efforts!!

  • @rashedkarim1944
    @rashedkarim19445 жыл бұрын

    Your tutorial was very helpful for me. Thanks A lot.

  • @psychoLeow
    @psychoLeow4 жыл бұрын

    You are absolutely amazing. :)

  • @chazbush2934
    @chazbush29344 жыл бұрын

    Amazing Tutorial Man!

  • @ataculsabiei
    @ataculsabiei2 жыл бұрын

    wow that was an amazing tutorial, really clear code and well explained

  • @VaderFaderVader
    @VaderFaderVader7 жыл бұрын

    Awsome!! I've litteraly just finished Part5, and was a little sad to miss the "User Manager" -part. And then the Updated version you mentioned 10 months ago, suddenly pops up. Thanks - your tutorials are really useful & informative. I'm learning a lot from you!.

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Hah! Suhweet! :-) I really hope I can deliver this time around. Been trying hard to get caught up after my move.

  • @alvinilmo8577

    @alvinilmo8577

    6 жыл бұрын

    can you help me with that error? and by the way thanks for the reply i really appreciate it. also thanks for uploading this video tutorial it really helps a lot

  • @jordanlesesne5901
    @jordanlesesne59014 жыл бұрын

    Great tutorial! Thank you!

  • @adriaancoetzee7238
    @adriaancoetzee72385 жыл бұрын

    Great Video, Thank you so much

  • @moseslauyihieng8436
    @moseslauyihieng84364 жыл бұрын

    Thanks for the tutorial! I really like the clean codes using classes, still learning for this skill :)

  • @w00blyn
    @w00blyn7 жыл бұрын

    awesome tutorial! thanks so much

  • @rowanbalana8578
    @rowanbalana85787 жыл бұрын

    I just discovered your channel and Holy adsadjaskdsajd you are saving my life now. I wonder why you don't get million of views! Thank you so much bro

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Awesome! Always happy to save a life! ;-D

  • @jackthehammer2245
    @jackthehammer22456 жыл бұрын

    Nice and smooth tutorial, thanks a lot.

  • @jasonjason8317
    @jasonjason8317 Жыл бұрын

    OOOH BUSTED, you gave it away! I saw that WoW folder, lol. Tell me you're not a night elf hunter named legolas :P

  • @VBToolbox

    @VBToolbox

    Жыл бұрын

    🤣 That was a looong time ago - but I was a gnome DK, back in the day.

  • @pw3111
    @pw31115 ай бұрын

    Just started this SQL series of videos after your Access ones. Excellent and a lot to learn😊

  • @VBToolbox

    @VBToolbox

    5 ай бұрын

    Awesome! Very happy you're enjoying the series! SQL server is still my favorite DB to work with. :-)

  • @yurishizu9
    @yurishizu96 жыл бұрын

    Thank you this series will help me with my project

  • @thiery572
    @thiery5725 жыл бұрын

    Interesting. I'll check out sometimes. Thanks.

  • @unicomp5705
    @unicomp57055 жыл бұрын

    Great detailed intro to using VB.NET with SQL Server... Thanks... Mike in LA, Calif, USA. Believe it or not I have made tons of money using MS Access/VBA as a front-end to SQL Server on a LAN because it's much quicker to build with and has a great report writer built-in. But at some point you will outgrow MS Access as a front-end(you can still use it for other smaller apps), and need more speed and more options as a front-end and that means going to C# or VB .Net Winforms(or WebForms - ASP.NET) to re-create that front-end. And that's me now... LOL... Thanks again for the info.

  • @VBToolbox

    @VBToolbox

    5 жыл бұрын

    UNICOMP Awesome! Now, if I could just get you to make me a tutorial on how to make tons of money (or even a little money) with Access and/or VB, that would be ultra rad! 😋 Thank you for the great comment!

  • @Chrissyhof
    @Chrissyhof3 жыл бұрын

    Great tutorial!! Best I have seen!

  • @waelhaddad2037
    @waelhaddad20375 жыл бұрын

    thank you so much , that was really good ,, thanks million times

  • @lorenzol707
    @lorenzol7074 жыл бұрын

    Great Video/ Learned a bunch

  • @norteclaportugal8829
    @norteclaportugal88294 жыл бұрын

    Great work. Thanks for this great job.

  • @FERRISHVAC
    @FERRISHVAC4 жыл бұрын

    Great Resource, Thank You Sir you're the best

  • @anthonypulsejr3521
    @anthonypulsejr35213 жыл бұрын

    You little marvel! You've gone and made functions into programs!!

  • @VBToolbox

    @VBToolbox

    3 жыл бұрын

    🤣 You're killin' me, Anthony!

  • @grossnut
    @grossnut3 жыл бұрын

    This is an excellent video series - written for VB2010 but I'm following easily in VB2017 SQL server 2017

  • @Ruud9010
    @Ruud90102 жыл бұрын

    wow, awsome, thanks for this, tomorrow I will start with part 2

  • @bradyaero
    @bradyaero5 жыл бұрын

    Well done!

  • @sriragkt
    @sriragkt4 жыл бұрын

    Awesome 👍

  • @khanglam4261
    @khanglam42615 жыл бұрын

    You are a legend...

  • @jRQLME
    @jRQLME3 жыл бұрын

    YOU ARE THE VB GOD

  • @ikramsyahpindolubis5747
    @ikramsyahpindolubis57474 жыл бұрын

    Never give up

  • @voice_of_habib
    @voice_of_habib7 жыл бұрын

    Thank you for nice tutorial.

  • @ahmadhussainwebshare1001
    @ahmadhussainwebshare10013 жыл бұрын

    Thx lot Bro . Very helpful tutorial . God bless you

  • @yekyawthu219
    @yekyawthu2192 жыл бұрын

    Excellent Teaching

  • @rafaelreis2632
    @rafaelreis26326 жыл бұрын

    Thanks man!! That's a wonderful video! I'll see every single one now! I'm initiating on Vb.NET now, after various developments in Excel VBA, and that helped me a LOT! Hope there's much more yet! Congratulations!

  • @jimohajibolaakinyemi8252
    @jimohajibolaakinyemi82526 жыл бұрын

    The tutorial is excellent

  • @ngotruongson3554
    @ngotruongson35546 жыл бұрын

    love you bro!

  • @mscoco1431
    @mscoco14314 жыл бұрын

    you are the best thank u

  • @ZorroUA
    @ZorroUA6 жыл бұрын

    Cooooool !!!! Thanks )))

  • @claudioabado3317
    @claudioabado33173 жыл бұрын

    Thank you!!!!!!!!!!!!!

  • @clashofclans6089
    @clashofclans60897 жыл бұрын

    awesome and really helpful code for learners.

  • @harryjames7654
    @harryjames76545 жыл бұрын

    Hi VBT Ill start by saying that this tutorial is absolutley fantastic!! - i was looking forever for a good video that explains this well so i'm really pleased you've taken the time to upload your knowledge to KZread for us all :) My Question is, willt his SQL Control Class work ok with a multi-user application accessing a single Database? or will conflicts still happen? Many thanks!

  • @ypapadim
    @ypapadim3 жыл бұрын

    Niiicee!!!!

  • @w00blyn
    @w00blyn7 жыл бұрын

    Hi, thanks very much for sharing your work! It's incredibly helpful. Do you if you could use your SQLControl class for an ODBC connection? Thanks!

  • @MohammedAbushagor
    @MohammedAbushagor6 жыл бұрын

    Amazing thanks alot

  • @RTKN197
    @RTKN1977 жыл бұрын

    Thanks bro

  • @dorothebertens8490
    @dorothebertens84905 жыл бұрын

    Love your tutorials. Do you have any with transaccions, love to learni more on this matter.

  • @macrobody
    @macrobody6 жыл бұрын

    Very nice stuff, just what I was looking for. I need to convert a semi large project in Visual Fox Pro to something new(er). This combination of Visual Studio and SQL server should be a way to make everything look and feel the same for the users.

  • @VBToolbox

    @VBToolbox

    6 жыл бұрын

    Awesome! I've had to do a bit of work in a SQL/VFP hybrid environment. Not gonna lie, I was tremendously happy to see VFP go the way of the dodo. :-P I had a VFP connector class [like my SQLControl] that would make it pretty easy to migrate data from VFP to SQL, but I recently moved and I'm not sure where that class went. :-(

  • @kenclemerbaltar532
    @kenclemerbaltar5327 жыл бұрын

    nice a new video :)

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Yes, indeed. Sorry that it has to be the same old topics, but it was long overdo and I still get a ton of questions on the old video so I really wanted to refresh them.

  • @kenclemerbaltar532

    @kenclemerbaltar532

    7 жыл бұрын

    always looking into your new uploads bro keep it up

  • @misperry
    @misperry3 жыл бұрын

    So how do you use the conneciton override you talked about? I would like to open another form and get user name and password info from user and then when they click the Search button it uses that for the connection. However, I run into lots of problems with not initializing the conenciton string on startup.

  • @BigIslandLavaPioneers

    @BigIslandLavaPioneers

    3 жыл бұрын

    You can add a new connection string at any point. The important thing is to not immediately run commands against it until it has had enough time to fully initialize. Opening the connection is fast, but even at milliseconds, commands in the same thread may execute faster than the connection opens. Just a thought. Are you testing the connection each time?

  • @misperry

    @misperry

    3 жыл бұрын

    Yep I figured it out. What I did was create a global string called strConnect and stored the connect string in that from a form. Then All I had to do is in the LoadGrid() sub add the line SQL = New SQLControl(strConnect). This uses the override constructor that the vid had seen and puts whatever string you have into the DBcon.

  • @justinshears879
    @justinshears8797 жыл бұрын

    Brilliant Videos for us newbies!! Building my first Program following as much of your work as I can, but have a real problem!!! I have copied Private Sub LoadCBX and renamed it, now I want to call up DataBase Column names only, so I can try and work out how to search with certain columns. Hope you can help BIG thank you !!!

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Are you thinking of something like a dynamic query - or populating a ComboBox with table or column names? I did a video on this for MS Access, but SQL Server is slightly different - a little easier actually. In a nutshell, your query will look something like this: [In your ExecQuery] SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'yourTable' After that, you populate your CBX from your DataTable [SQL.DBDT] just like you normally would with any other query. I hope that helps! :-)

  • @justinshears879

    @justinshears879

    7 жыл бұрын

    Really sorry for late reply as you replied straightway to me!, but I was like a child with new tool, got all excited and went off and watched your Access tutorial, and that was exactly what i was after. Thank you so so much!!!! Your brilliant

  • @InaGalaxyFarFarAway
    @InaGalaxyFarFarAway6 жыл бұрын

    Excellent job with the videos. I hope all is well. I've used your instructions to get me going in the right direction for my project and I thank you for that. I do have one question though. Would you know of any resources that I could check out that would help me with being able to search my database using multiple keywords that are typed into a single textbox? I assume I would have to cycle through the words and split them apart which would allow me to search by each word; however, I don't really know the process for that and how to return the search results and display them into a listbox instead of a datagrid.

  • @DiyintheGhetto
    @DiyintheGhetto7 жыл бұрын

    Hello I haven't visit your videos in a while. I been away But again very nice video keep up the great work.

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Always great to see you, Joseph! I apologize for my slow responses. I'm still getting settled from my move and it's been difficult to keep up with all of the comments and questions and even more difficult to make new content. I'm trying to get caught up, though. :-)

  • @DiyintheGhetto

    @DiyintheGhetto

    7 жыл бұрын

    I didn't know you moved. I'm soon to move my self.

  • @VBToolbox

    @VBToolbox

    7 жыл бұрын

    Yep, and I'll be moving again in less than a year, so it's going to be hard to keep up but I'll do what I can. I hate moving, but we gotta chase those goals and dreams, right?

  • @DiyintheGhetto

    @DiyintheGhetto

    5 жыл бұрын

    Just a update how did the move go? I know it has been a while so i was wondering. I also moved to Georgia my self.

  • @dorothebertens8490
    @dorothebertens84906 жыл бұрын

    Very clear, simple and easy to undestand for us beginners. Used your override sub from the DBcontrol class, ( new(connectionString) and getting a type exeception. How to fix ?

  • @serkancanbaz1
    @serkancanbaz1 Жыл бұрын

    Thanks

  • @derrickwalker3018
    @derrickwalker3018 Жыл бұрын

    Great work! How do you call the new connection string?

  • @michaelnewman9645
    @michaelnewman96457 жыл бұрын

    Another great tutorial. Are you a programmer by profession?

  • @Knych-nr4ot
    @Knych-nr4ot6 жыл бұрын

    Awesome video!, Im using Vb.net 2017 express windows form and connecting to sql server 2017 express, i would like the users when they run the program to be able to select what database to load. I tried setting up a textbox where the users will have to paste the location of the dbase then later on connect with the use of a button. However, it says value of Strong cannot be converted to connection (which is dim connection as new sqlconnection)

  • @bachphi1
    @bachphi15 жыл бұрын

    Hey VB Toolbox, Can you do a series of using Entity Framework since it is the recommended method by MS. Thanks

  • @niloydas6581
    @niloydas65817 жыл бұрын

    Hi, i need to store an integer value from one of the cells to a variable. I need to use Execute Scalar but i cant understand how to call that using the SQLControl class. Can someone help please?

  • @jasontodt836
    @jasontodt8364 жыл бұрын

    I enjoyed your video! great work. Would you mind showing how to allow the end user to map and connect to a SQL database please? Example would be to place the SQL database onto a shared drive and multiple end users would be able to locate and connect through a mapped drive. Thank you for all your videos!!

  • @ahmedabdelwahd9520
    @ahmedabdelwahd95205 жыл бұрын

    thanks for the class can you send converter of this class to work with Xamarin Android class

  • @pramodnegi7131
    @pramodnegi71317 жыл бұрын

    Thanks for sharing knowledgeable video. You are an Erudite Person. Can you please help in to use the program to get multiple return parameters.

  • @vule562
    @vule5627 жыл бұрын

    First I want to say Thank You. I have a question that I got a search form with datagridview and I tried IF SQL.RecordCount > 0 do something ELSE do something but it was not working. Thanks

  • @jamesoconnor1056
    @jamesoconnor10564 жыл бұрын

    Great video. I tried adapting your solution to an asp.net web enabled solution but the GridView displays as empty on my first web page when it's displayed. Have you made a similar video illustrating how to do this as a web solution using asp.net rather than forms?

  • @GautamBhatia713284
    @GautamBhatia7132842 жыл бұрын

    do you take private online clasess plesae let us know "Please do it"........ Good teachers are real valuable asset and very hard and rare to find

  • @VBToolbox

    @VBToolbox

    2 жыл бұрын

    I kinda wish I could, but it's extremely difficult where I live now. Also, I'm terribly out of practice since I haven't coded much in several years.

  • @anthonypulsejr3521
    @anthonypulsejr35213 жыл бұрын

    I could hug you! GET OUT OF THAT CHAIR AND LET ME!

  • @VBToolbox

    @VBToolbox

    3 жыл бұрын

    😆

  • @garywittlock5077
    @garywittlock50776 жыл бұрын

    I can not seem to get the sample tutorial to work. It keeps complaining about the server connection. DO I need to do something with the bak file? Can this tutorial work with SQLite?

  • @ghassansalem1711
    @ghassansalem17112 жыл бұрын

    Great presentation, Thank you very much, I am having an error when filling DBDT, message(DBDT is not a dataset (I am using VS 2019), Can you please help

  • @vinnypassmore5657
    @vinnypassmore5657 Жыл бұрын

    Hi, thanks for sharing, great stuff, how about calling stored procedures ?

  • @VBToolbox

    @VBToolbox

    Жыл бұрын

    Hi, Vinny! Not sure if you already saw it, but I just recently released a video on this topic. 🙂

  • @niketagarwal5008
    @niketagarwal50087 жыл бұрын

    Hey! I am facing a problem when I try to connect to my server using an IP address. Error pops up saying- "The server was not found or was not accessible". Is there anything wrong in the connection string?

Келесі