| by Kenneth Chase | 100 comments

Programming in Visual Basic .Net How to Connect Access Database to VB.Net


Hello to all Youtube audiences. The first step is to create the new database. Right click on an empty space. After that, select ‘New’. Then select ‘Microsoft Office Access 2007 Database’. We have to name our database. For example, it’ll be named Your_Database which the file extension is .accdb After that, hit ‘Enter’ on the keyboard or double click on the file. ‘Access’ program will automatically open. Then we will create a new table to collect data. Go to ‘Create’ tab and choose ‘Table’. Right click and choose ‘Design View’. The program will let us name the table. I will name it ‘Table1’. Add a new field. You can follow my lead. ‘YourName’ field, in this case I mean ‘First Name’. The data type is Text. ‘LastName’ field is for keeping last names. It has same data type with ‘YourName’. ‘Phone’ field is for keeping phone numbers. The data type is also Text because we don’t mathematical calculate it. ‘Email’ is for keeping email addresses. The data type is Text. ‘Facebook’ field is for keeping Facebook accounts. (This one is optional). After that, right click on the table header and hit the ‘Save’ button to save. Then, choose ‘Datasheet View’ to view the data. It will look similar to the program ‘Excel’. For now, close the program ‘Access’ then open ‘Visual Studio. We will create a new project. Click ‘New project…’ in ‘Start Page’ or go to ‘File’ menu and choose ‘New –>Project…’. Choose ‘Visual Basic –>Windows’ then choose ‘Windows Forms Application’ in order on the right tab. Now, name our project. I’ll use the one that the program named which is ‘WindowsApplication1’. We will find an empty form name ‘Form1’ which is automatically created by the program. Click ‘Save’. Click ‘Toolbox’ on the right tab and then choose ‘Dock’ to always show this window. Here, we can satisfactorily adjust the form size. I will add ‘TextBox’ and ‘Label’ control by dragging it from ‘ToolBox’ window to our form. Then reposition it wherever you want. I will add a Button into the form. For User to use commands such as save or delete by clicking it. We can browse qualities of the controls by right clicking on the specific control and choose ‘Properties’. The ‘Property’ window will be showed on the right. I will hide the ‘ToolBox’ window by choosing ‘Auto Hide’ to provide more using space. Then, change the text on ‘Label’ control to be meaningful by adjusting in ‘Property Text’. I will change the text to ‘Name:’ or ‘First Name:’. Copy more ‘Label’ & ‘TextBox’ controls until it completed the number in the field we created in the data base. You can follow my lead. Then, change the text in every ‘Label’ control to be meaningful and appropriate. The second one will change to ‘LastName’. The third one will be ‘Phone’. The fourth one will be ‘Email’. The fifth one which is the last one, will be changed to ‘Facebook’. Do the same thing on Control Button. The first button, I will change the text to ‘Previous’. Copy all the buttons as you wanted. In this case, please follow my lead. After that, change all the text in every button. Change the text to ‘Add New’ on the second button. Change the text to ‘Next’ on the third button. Change the text to ‘Save’ on the fourth button. Change the text to ‘Delete’ on the fifth button. Change the text to ‘Close’ for closing the present form on the sixth button which is the last one. In case there is an only form, the program will be closed. Next, adjust the size of every ‘TextBox’ controls as you wanted. Then, I will hide the ‘Properties’ window for now and I will open ‘ToolBox’ window instead. Add 2 ‘GroupBox’ controls to the form for categorizing controls in the form to nice and tidy. Adjust the form to an appropriated size. We will find that the ‘GroupBox1’ is covering other controls. Right click and choose ‘Send to Back’. Arrange the position and adjust the size of the controls on the form. Here, you can follow my lead. Next, I will add ‘DataGridView control’ into the form. This control is used to show data from the database. Click and drag it to ‘GroupBox2’ control. Hide the ‘ToolBox’ window for now. Adjust the size of ‘DataGridView’ as you wanted. If the form is too small, we can adjust the size into any sizes we want. It might take some times. You can follow my lead. After you are satisfied with the adjustment, click ‘Save’ to save. The next step is to add a data source by choosing from the Access database into our project. Go to ‘Data Sources’ window on the left, choose ‘Add New Data Source’ button. ‘Data Source Configuration Wizard’ window will be appeared like this. Choose ‘Dataset’ then choose ‘Next’ and ‘Next’ again. Click ‘New Connection…’ button then choose ‘Browse’ to choose a database file the we created. Click ‘Test Connection’ button to test the database connection. Click ‘Next’ then ‘No’ because we will manually copy the database file into the project. Click ‘Next’ again then check (check mark) all of it. Click ‘Finish’. Next, I will add data source to the ‘DataGridView’ control. Click the triangle button on the right corner then choose ‘Data Source’ which is ‘Table1’ in this case. Click the check mark before ‘Enable Column Reordering’. We will find that the table header text will appear on ‘DataGridView’ which we can use the data from the table we created. Here, we can adjust the size of form and controls as you wanted. You can follow my lead. Next, I will hide the column ‘ID’ from User sight because this field is AutoNumber. Change it from ‘True’ to ‘False’ at ‘Visible’ then click OK. We will find that ‘ID’ column is gone (hidden). If the window is too small, we can adjust the form size for a nice appearance. It might take some time. Next step, I will create ‘Data Bindings’ or binding the data from the field in the data source to every ‘TextBox’ control. Right click on the first ‘TextBox’ then click ‘Properties’. Look for ‘DataBindings’. At ‘Text’, choose ‘Field’ from ‘Table1BindingSource’ that will be bound with the first ‘TextBox’. In this case, it is ‘YourName’ field. (Please choose the correct one). Do it to every ‘TextBox’. Follow my example. Next is ‘LastName’. Do the same step which is selecting the correct data field. Next, Do the same with ‘Phone’, ‘Email’ then ‘Facebook’. Recheck that we correctly did ‘Data Bindings’ to every ‘TextBox’. After we finish, click ‘Save’ button to save. Then, we will write command code for the buttons. Start with the ‘Previous’ button. Double click on the button, there will be ‘Event Handler’ command code for automatic mouse clicking. First command is to move the record 1 row previous. Please follow my lead. Next, ‘Add New’ button for adding new data. You can see that the commands are quite similar, just a little adjustment. Next, ‘Next’ button for moving the record to the next one. Next, ‘Save’ button for saving data to the data base. This command is little longer than others. We will use TableAdapter to help in adding and updating data that we changed in the Dataset to be saved in ‘Table1’ table in Access database. Normally, we should write a command code for finding errors in the program. Use the command ‘On Error Goto’. It means what will the program do after an error happens. Mostly, it will show error messages then quit working. In this case, if there are any errors while saving data, the program will jump to ‘SaveErr’ command that we created. You can see that there is a : (Colon) after the command name. In the example, it is SaveErr: In this case, if there are any errors, I will let it quit working by the ‘Exit Sub’ command. In case the saving is flawless, it will show that the saving is complete by using ‘MessageBox.Show()’ command. You can follow my lead. Please always save the data while working. Next, ‘Delete’ button for deleting a data row. The command is quite the same. In this case is ‘RemoveCurrent()’. The last button, ‘Close’ button is for closing the form. If there is only one form, it will quite the program. Short command, ‘Me.Close()’. Click ‘Save’ button after finish. Check everything. Adjust the form as you wanted. After that, we will test the program. Click the green button (Start Debugging) or click ‘F5’ button on the keyboard. We will see the form shows like this. When you need to add data, click ‘Add New’ first. If you accidently click it for several times, there will be rows added according to the numbers of the click. Click ‘Delete’ button to delete the rows. After that, test typing details to every ‘TextBox’. You can follow the example in the video. In this part, I will use hypothetical data, not real data. After we finish typing, click ‘Save’ button to save data every time. We will see that if there aren’t any errors, program will show the text that we inserted. If we want to add new data, we have to click ‘Add New’ button every time like before. Then, type details the every ‘TextBox’ as you wanted. Click ‘Save’ button after finish every time. I will add more data to use as an example. Here, we can test the running by ourselves. This part, underline that we have to click ‘Save’ button after typing or adjusting any data. If not, the data will not be saved. If there are enough data, test the navigation buttons (Previous – Next) to see… if it can correctly move previous or following records. Test clicking ‘Close’ button to close the form and quit the program. You will see that the program stops working. We will see that the data we added appears in every ‘DataGridView’ and ‘TextBox’. Go in our Access database to see our real data first. We will find that there is the data we added is already here. OK. Close ‘Access’ program and the opened form for now. We will start testing the program again. I will add more data for the test. You can add whatever data you want. After that, click ‘Save’ to save every time. Click ‘Close’ to close the program. Then go check the data in database again. You will find that the new data has been added. Adjust the back color of the both ‘GroupBox’ for a nice appearance. You can follow my lead. Click ‘Save’ and click ‘Start Debugging’ to run the test again. Choose a row that you want to adjust. When finish adjusting, click ‘Save’ button to save data every time. *** If you want to delete, choose the row you want from ‘DataGridView’ then click ‘Delete’ button. After that, click ‘Save’ button to save data every time.***

100 Comments

Ali Bhai

Sep 9, 2019, 2:52 pm Reply

uploadind pe eror dy rha h bhai

Ali Bhai

Sep 9, 2019, 2:52 pm Reply

apload pic krta hu tu erorr show ho rha h is ka kia hal h

Cuong Nguyen

Sep 9, 2019, 3:44 pm Reply

cute bro

Ikram Khan

Sep 9, 2019, 1:59 pm Reply

Informative
#infoandentertainment

Leila Ayachi

Sep 9, 2019, 7:24 pm Reply

thank you

Phil Paxman

Sep 9, 2019, 10:37 pm Reply

VB is not that difficult

My Family FunPH

Sep 9, 2019, 1:39 am Reply

nice tutorial thank you

Mary Jean Apat

Sep 9, 2019, 4:49 am Reply

Wow it's nice channel

Karen Payne

Sep 9, 2019, 1:49 pm Reply

If we want VB.NET developers to be first class citizens in the ecosystem there needs to be a move from TableAdapter methods for working with any database. Even suggesting TableAdapter methods makes it hard to consider modern possibilities like DataAdapter, working from connection and command objects to Entity Framework Core (or EF6). Even when this video is with Visual Studio 2010 developers (using Visual Studio 2013 and higher .eg Visual Studio 2019) will still find this and consider TableAdapter methods valid, especially with the appearance of an easy solution to work with Microsoft Access, SQL-Server etc.

Rhonda Webster

Sep 9, 2019, 3:28 pm Reply

not going to waste my time watching a video where he clicks things too fast to see and there is NO AUDIO!

Joenethia White

Oct 10, 2019, 3:31 am Reply

Thank you for the conversation tonight. There is no audio on some of these. I see nothing good on this. the conversation was good but i don't see were anyone have it and say how good it is. Will call you back

sandy rojas

Oct 10, 2019, 3:32 pm Reply

Funciona al 100

erez simon

Oct 10, 2019, 4:44 pm Reply

GREAT VIDEO

hertha stewart

Oct 10, 2019, 7:02 pm Reply

jkuvbccv

Than Naing

Oct 10, 2019, 7:53 pm Reply

New data can't be added after delete some data and then showing err msg,why ?

The Best Technical 360

Oct 10, 2019, 8:02 pm Reply

Great and easy way of explaining the
topic, thank you very much.

Quilès Michèle

Oct 10, 2019, 11:39 pm Reply

Merci beaucoup ! Vos conseils m'ont bien aidée !

Joe Macs

Oct 10, 2019, 7:49 am Reply

Very good teacher, the best so far for explaining this stuff elementor

Iprofit DotWs

Oct 10, 2019, 7:49 am Reply

Thank You For Posting This!

Yengyeng Fado

Oct 10, 2019, 8:13 am Reply

wow salamat sa pag turo po

Ronaldo Jaegher

Oct 10, 2019, 8:54 am Reply

Rápido demais para iniciantes

aa bb

Oct 10, 2019, 1:24 pm Reply

Thanks for refreshing my old memories. I made a video rental shop and GPS management application of VB.Net but couldn't continue programming later on.

van na kH

Oct 10, 2019, 3:34 pm Reply

Hi bro 377+

Duc Khai Tong

Oct 10, 2019, 4:16 pm Reply

omg. i'm here in 2/10/2019. 26.173.268 views and so on …

saphulele Ngcobo

Oct 10, 2019, 6:46 pm Reply

I have got a question anyone who can assist? I would like to know that if you are doing FOR LOOP inside DO WHILE IN VB.NET
is it essential to have initial prompt instruction and Accept instruction outside the DO WHILE before you begin the DO WHILE?

edilsonjotasilva2

Oct 10, 2019, 10:31 pm Reply

fiz 30 vezes e não deu certo, creio que esse jxl não seja compatível com a ultima versão do java, alguém poderia postar os códigos por favor, obrigado!

Kathy Rowland

Oct 10, 2019, 12:03 am Reply

The Conversational Forms is intriguing, but not sure it's something I need for my newish blog at this point. Lots of fun and powerful things to consider.

Rosa María Paniagua de Barry

Oct 10, 2019, 1:26 am Reply

No funciona

joel secretaria

Oct 10, 2019, 5:59 am Reply

thanks for sharing bro.GOD Bless

AboveOrbit

Oct 10, 2019, 6:50 am Reply

Am I the only one confused by the 27 million views on here?

Raj Naidoo

Oct 10, 2019, 7:02 am Reply

can you classify 14 classes of vehicles

targarin Бажина

Oct 10, 2019, 12:06 pm Reply

Very good teacher, the best so far for explaining this stuff elementor

Stive Robarts

Oct 10, 2019, 12:36 pm Reply

i alredy download and customize flashlight app. thank you so much brother

DaKingInDaNorf

Oct 10, 2019, 8:43 am Reply

Thank you good sir. With this information I can finally track the killer's IP address!

Manigandan Rajagopal

Oct 10, 2019, 2:46 pm Reply

if this much fast he is doing , how can we get knowledge. no use of this video.

Michael Brenner

Oct 10, 2019, 11:51 pm Reply

After downloading theme visual studio, meen mean, fire fox to beta chrome blue I'm left with 3 minutes pin on excel Nd power point works with u-tube but not working flix. if you get my drift.

Trieu Truong

Oct 10, 2019, 3:52 am Reply

Thank you so much for posting these helpful videos.
It helps me a lot in learning .NET tutorial.
I'm your fan now.

Sarim Malik

Oct 10, 2019, 5:01 am Reply

I am having problems with the "save" button, particularly this statement…"Table1TableAdapter.Update(Your_DatabaseDataSet.Table1)". The software just points out an error and says that this statement is not "declared". Does anyone have any bright ideas ???

Nadeshiko Tsukiyomi

Oct 10, 2019, 7:03 am Reply

very helpful thank you very much. im planning to make 3 types of database but i dont know how can i make a program on how to integrate them altogether in one program. could you help me? i know a few things in this since im new i want to learn.. thanks

Jim Boyd

Oct 10, 2019, 4:19 pm Reply

Thanks so much. Looked everywhere and finally found your directions. Even a dummy like me can understand!

Armando UaNDM

Oct 10, 2019, 8:43 pm Reply

Thank you !! Subscribed! XD

Alekaditez

Oct 10, 2019, 12:58 am Reply

Watching in 2019.

Lugo Master

Oct 10, 2019, 10:36 am Reply

nice

Jonathan R.

Oct 10, 2019, 12:59 pm Reply

Love the hidden message of the date, give all a guess May 1843 at the exact start time of this video,,, of screw it, the mean pi of distance from earth to the moon on May 16th 1843 at the start of this video, why? and why is he listening to a loca rockl legend in South Carolina now since dead

Horny Katie

Oct 10, 2019, 2:59 pm Reply

Nice video 😀

david he

Oct 10, 2019, 9:10 am Reply

i alredy download and customize flashlight app. thank you so much brother,thanks

Razvan Florescu

Oct 10, 2019, 9:33 am Reply

Why to do this in VB.net, instead of design forms directly in Ms Access ?

Matt Roberts

Oct 10, 2019, 1:33 pm Reply

This is so helpful, took me 3 weeks or learning to get this but you taught me this in 19mins

Nicholas Starns

Oct 10, 2019, 3:26 pm Reply

dis is my Video

varun aggarwal

Oct 10, 2019, 5:51 pm Reply

Thanks dude.

Jessica rubi lopez diaz

Oct 10, 2019, 7:07 pm Reply

Muy buena lección el día de hoy. FUCK YEAH

Nicholas Starns

Oct 10, 2019, 7:20 pm Reply

hi

Thats My Nibba!

Oct 10, 2019, 11:23 pm Reply

Thanks this really helped me, and actually taught me something.

bharat k

Oct 10, 2019, 9:33 am Reply

27M views how can VB6 app can make it…:(

Toni Gamer123

Oct 10, 2019, 5:04 pm Reply

lol calendar says 13th december 2556

Deder Cb

Oct 10, 2019, 5:40 pm Reply

mantap bosku….

Mike Y

Oct 10, 2019, 6:32 pm Reply

Huge thanks. Bizarrely, there used to be a setting on the P9's that allowed what you're talking about by default, but a new secondhand one I bought no longer has this option. Therefore your option seems to be the only solution on my current P9!

ItzCtOfficial

Oct 10, 2019, 9:47 pm Reply

Eric Johnson

Pete Koma

Oct 10, 2019, 10:58 pm Reply

Thank you!! It was making me crazy

Kevin

Oct 10, 2019, 10:59 am Reply

27M view for a VB tuto ? With 11k likes ? WTF ?

Nazmul Hasan Kazal

Oct 10, 2019, 3:34 pm Reply

I donno wtf is all these, just clicked cz it has 27 million views!

Hell Radio FM

Oct 10, 2019, 4:22 pm Reply

I wanna learn coding

Dafa Harvanza Official

Oct 10, 2019, 10:53 pm Reply

mantab

Carole Morrissette

Oct 10, 2019, 1:33 pm Reply

Mes chansons Carole Morrissette

Sharon Richardson

Oct 10, 2019, 5:40 pm Reply

Thanks so much!!

Penny Briscoe

Oct 10, 2019, 7:15 pm Reply

horrible, too fast ,no sound, no explanation, trying to sell online course, bs!!

郭崑山

Oct 10, 2019, 7:44 am Reply

Use SQL mode to connect access.mdb

JohnnyC Major

Oct 10, 2019, 2:55 pm Reply

I don't even know what this is.

Faith Egwuenu

Oct 10, 2019, 9:08 pm Reply

Thank I learnt something new on Figma today

Satheesh Veedu

Oct 10, 2019, 5:44 am Reply

THIS IS SO HELP FULL,THANKYOU

AdiTube

Oct 10, 2019, 10:50 am Reply

fabulous very hard working

Selina kew

Oct 10, 2019, 4:37 pm Reply

I’ve been waiting for one of these videos for such a long time! Thank you!

Rico Soliman / Father & Sons

Oct 10, 2019, 8:08 am Reply

HI. THANKS FOR THIS INFORMATION. SO INTERESTING. GOD BLESS.

Business House

Oct 10, 2019, 12:41 pm Reply

wow

Даша Круглова

Oct 10, 2019, 9:12 pm Reply

Try Utopia ecosystem, you will like it!

9437810

Oct 10, 2019, 9:50 pm Reply

87564400 action, anybody hit the blue board yet, I did

Daveen Stubbs

Oct 10, 2019, 12:27 am Reply

This just save my life!!!! Thank you so much for sharing <3 <3

EnricoJoseph

Oct 10, 2019, 10:42 am Reply

The data is not save on my database how to fix it?

Sahin Islam

Oct 10, 2019, 2:14 pm Reply

Thanks for sharing your idea.this is a good job, carry on.

Karen A Fine Balance

Oct 10, 2019, 5:01 pm Reply

simple but essential advice. thank you

Eduardo Montes de Oca

Oct 10, 2019, 6:01 pm Reply

theres is no "3d on/off" option for me. i only see "label" in that spot

GOVIND MISHRA

Oct 10, 2019, 5:32 am Reply

Before coming to route how do token authentication in web api??

ครูพี่กบ

Oct 10, 2019, 7:28 am Reply

Good Thank Master…

Carrie Parrish

Oct 10, 2019, 7:43 am Reply

You know who’s the greatest?

Galfand Berger, LLP

Oct 10, 2019, 10:13 am Reply

Do I get paid if I get injured at work UK

Alien Gaming

Oct 10, 2019, 12:15 pm Reply

you are proestttttt

demosteam

Oct 10, 2019, 8:13 am Reply

How does this have almost 29 million views

Diane S

Oct 10, 2019, 4:29 pm Reply

Thank you! Ended up adding them three times!! Now I have to figure out how to fix that! :p

Mertcan Seğmen

Oct 10, 2019, 5:14 pm Reply

Why do i always end up in this video

Johney Munni

Oct 10, 2019, 6:24 pm Reply

Leute, meckert nicht rum. Du kannst doch selbst sein System ohne Kapitaleinsatz im Casino Deiner Wahl testen. ( Falls Du gerafft hast wie es geht) Falls nicht, oder es funzt nicht; DANN EBEN NICHT

Pawan kumar gupta

Oct 10, 2019, 6:37 pm Reply

great save on database fix it

Senith Samaranayake

Oct 10, 2019, 12:30 am Reply

very helpful. thanks heaps

Nanimai mai

Oct 10, 2019, 12:48 am Reply

great project

Ati Evans

Oct 10, 2019, 5:49 am Reply

Great video with helpful information. It has really helped me a lot. I truly love this video. Keep it up bro.

cjfolk 28

Oct 10, 2019, 6:15 pm Reply

No audio?

Sophia Hsu

Oct 10, 2019, 9:48 pm Reply

too complicated for me, I don't understand, yeah, why it shows come from 2556, I am very confuse.

Keiy Teo

Oct 10, 2019, 2:22 am Reply

thank you so much!!

happy himon

Oct 10, 2019, 3:23 pm Reply

very nice video

vinay dilip

Oct 10, 2019, 5:15 pm Reply

hi, may I know how is this done ?? can you make an explain or make a video over this plugin https://www.youtube.com/watch?v=rSThA-pYiwc

Kirk Nel

Oct 10, 2019, 6:25 pm Reply

This makes so much sense now

Leave a Reply