Microsoft Visual Basic Online Course, solutions,tutorials and lessons for beginners and intermediates, OOP lessons, how to connect your database in vb.net how to work with SAP Crystal Reports in vb.net, how to create a small business application in vb.net, how to create vb.net tools and controls, vb.net step by step, full application's source codes, how to be a freelancer in vb.net and earn some money. Read mail in Visual Basic 2010, how to read e-mail inbox by Visual Basic .Net
Visual Basic 2010 with MS-Access Database
Get link
Facebook
X
Pinterest
Email
Other Apps
Understanding ADO .Net for Visual Basic 2010 and Microsoft Access 2003 / 2007 Database
Visual Basic .Net and Ado.Net for MS-Access Database course online
There are two methods to work with MS-Access 2003/2007/2010/2013/2016/2019 Database (*.Mdb / *.Accdb) from Visual Basic 2010 using ADO .Net technology .
With .NET, Microsoft has released a new mechanism for accessing data: ADO.NET. The name is a carryover from Microsoft's ADO (ActiveX Data Objects) technology, but it no longer stands for ActiveX Data Objects--it's just ADO.NET. To avoid confusion, I will refer to ADO.NET as ADO.NET and to ADO as classic ADO.
If you're familiar with classic ADO, be careful--ADO.NET is not a descendant, it's a new technology. In order to support the Internet evolution, ADO.NET is highly focused on disconnected data and on the ability for anything to be a source of data. While you will find many concepts in ADO.NET to be similar to concepts in classic ADO, it is not the same.
Method (1)
Online mode or Connected mode or connected model
ADO.Net Connected model, Ado.net connected mode
Ado.Net Online-mode (Connected Mode) is just like the same old method we used to work with Databases from Visual Basic 6.0 and ADO2.8 version, all you need to do is :
Create Access Database and a Table with your fields.
Define the Database path
Include ADO2.8 Reference into the Visual Basic 6.0 project
Connect the Database
Open the Database
Operate your events (Save, Edit, Delete and find)
Exit the VB6 Project and you will find the data in the Table were affected if events were processed correctly in the VB6 Project.
And the this is the same logic with ADO.Net in Visual Basic 2010 and MS-Access 2003/2007. The difference is in coding interface, but also the logic is the same some how, more than VB6 Coding, but more understandable.
An example to the Online-mode with MS-Access 2003, is the Friends_Info. Basic code to connect to a MS-Access Database 2003/2007 from Visual Basic 2010 using the ADO.Net Online-Mode is :
ADO.Net connected model example source code vb.net
♦ Connect to and Open Database :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method (2) Offline mode or Disconnected mode or disconnected model
Ado.Net disconnected model
You will see the difference now of using ADO technology only if you are familiar with classic ADO that we used to use in Visual Basic 6.0, but if you did not use it before that you won't.
ADO.Net Offline mode or the Disconnected method of working with Databases has a nice and easy logic :
♦ ADO.Net disconnected model works great with Client/Server applications
ADO.Net method is the preferred way to code client/server applications. The DataSet object is what the ADO.Net offline/Disconnected mode is all about, it gives you the ability to work on the Database components separately (it stores a Database copy in the Memory - RAM of the client machine while working on the Database components), so it gives you the ability to create multiple tables, fill them with data coming from different sources, enforce relationships between pairs of tables, and more.
♦ ADO.Net Offline mode is not recommended for ASP.Net
♦ Though the Dataset is a great choice to work with Client/Server applications, but when working for example with ASP.Net live pages, it is a bad choice because the ASP.Net pages don't live long before they finish their lifetime cycle.
The above Friends Info VB.Net project using ADO.Net offline mode basic codes as follow :
◘ Connect to and Open Database :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I will discuss working with Crystal Reports for Visual Basic
.Net in details in another post, starting Downloading SAP Crystal Reports until Packing SAP Crystal Reports and install it on the client's machine. Keep up !
Another topic about ADO.Net generally, is the ability to Create/Delete/Back-up Database, Add/Modify/Delete/Back-Up Tables and Queries using the OpenSchema method. Let's see how to do this in Visual Basic .Net 2010.
→ VB2010 : To Create new Database using ADO.Net, you will need to add new reference to your project to AdoX (Microsoft ADO Ext. 2.x for Dll and Security) ...
Create new Database in Visual Basic 2010
→ VB2010 : To list all Database files from a Dir. into a TreeView control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
→ VB2010 : To manage Tables using OpenSchema method
→ VB2010 : To manage Fields using OpenSchema method
Some Visual Basic Exceptions and Solutions Working with MS-Access 2003/2007
Exception: "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key Information" Solution :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exception: "Syntax error (missing operator) in query expression ''He's')'.", while trying to Execute INSERT INTO Statement which carries String Values that contain Apostrophe like (He's)" Solution :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connection String : The OleDB Connection String used to connect Microsoft Access Database 2016 (accdb) with Visual Basic 2015 (.Net FrameWork 4.5) Win10 32bit [WinForm] Project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code to close all Connection to Microsoft Access Database after exit windows form application in VB.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VB .NET DropBox Api Example Create a Desktop Application using VB .NET and Dropbox Api VB .NET Dropbox Api Example Requirements Visual Basic 2010 [recommended VS 2015] or above (Visual Studio 2019) from here Visual Basic previous Example from here Dropbox Account from here .NET Framework 4.0 or above for above VS versions. Dropbox Api for current .NET Framework version of yours Open VB 2015 Project in VB 2019 Can I open / migrate Visual Basic 2015 Project Source Code with Visual Basic 2019 ? The answer is Yes, if you want to more details about VB 2015 to VB 2019 migration, please read Project description I will use the VB.NET example from previous post to add a functionality to it. I will add Backup Database to Dropbox [ToolStripMenuItem] VB.NET Dropbox Database file Backup When a user press [ToolStripMenuItem -> Backup to Dropbox] : The VB.NET application does the following : Checks for Internet Connection Status. Connects to Dropbox Appli...
CodeProject VB .NET Google Drive Api Source Code Example VB .NET Google Drive Api Source Code Example Requirements Visual Basic 2012 [recommended VS 2015] or above (Visual Studio 2019) from here Visual Basic previous Example from here Google Account from here .NET Framework 4.5+ or above. "Async Programming" Google Drive Api [Google.Apis.Drive.v3] from NuGet here Open VB 2015 Project in VB 2019 Can I open / migrate Visual Basic 2015 Project Source Code with Visual Basic 2019 ? The answer is Yes, if you want to more details about VB 2015 to VB 2019 migration, please read VB.NET Google Drive Api v3 post key points How to use Google Developer Console to create a project. How to Configuring Google Api Console How to Install Google Drive Api v3 from Visual Studio 2015 How to Upload Simple file to Google Drive using Google Drive Api v3 from VB.NET How to Upload Large Files (Resumable Upload) using Google Drive Api v3 from VB.NET Asy...
VB.NET Access 2007 Hierarchical TreeView visual Basic .Net project Hierarchical TreeView VB.NET Hierarchical TreeView Project requirements VS 2010 / 2015 .Net FrameWork version 4.5 [Properties : Enable -> Make single instance application] Compile option -> Target CPU : x86 MS Access 2007 / 2010 (*.accdb) VB.NET Hierarchical TreeView Project logic Populate Access 2007 Database Tables with Data from Visual Basic 2015 Form Controls [TextBox] Display or populate TreeView control with Hierarchical Data From Microsoft Access 2007 Database (*.accdb) Display or populate TreeView control (Parents / Child) with search results from Access 2007 and highlight search results. Perform Insert, Update, Search, Delete commands to/from Access 2007 Database from VS 2015 Form Control MenuStrip. VB.NET Hierarchical TreeView Project steps summary Create Microsoft Visual Basic 2015 Project [Desktop Classic] Windows Form Applicat...
VB.NET How to properly close a windows application Form VB.NET How to properly close a windows application Form Requirements Visual Basic .Net (any version) , VB2010 and up recommend .NET FrameWork 4.0 and above recommended How to properly close a windows application Form in VB.NET ? You may close a Form in VB.NET Application [WinForm] by : KeyPress event Before you test this code you need to set the Form Property [KeyPreview] True, from Form Properties Window. The code below will Read Keyboard button [Escape] when clicked and Executes Close() Private Sub MainFrm_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress If e.KeyChar = Chr(Keys.Escape) Then Close() End If End Sub Then in the FormClosing() event, we will place a code to display a message [MsgBox] with [Yes, No, Cancel]. If the user clicked [Yes] then it will...
How to connect Access Database using DAO In VB .Net vb .net DAO Data Access Object (DAO) According to Microsoft Docs , Conversion from DAO TO ADO : Versions of the DAO library prior to 3.6 are not provided or supported in Access. Also : ODBCDirect workspaces are not supported in Microsoft Access 2013. Use ADO if you want to access external data sources without using the Microsoft Access database engine. DAO is used with Access databases and is supported through Office 2013. DAO 3.6 is the final version, and it is considered obsolete. These classes work with the other application framework classes to give easy access to Data Access Object (DAO) databases, which use the same database engine as Microsoft Visual Basic and Microsoft Access. The DAO classes can also access a wide variety of databases for which Open Database Connectivity (ODBC) drivers are available. Programs that use DAO databases will have at least a CDaoDatabase object and a CDaoRecordset object. DAO 360 d...
OleDB Error There is already an open DataReader associated with this Command which must be closed first. OleDB Error : There is already an open DataReader associated with this Command Problem There is already an open DataReader associated with this Command which must be closed first. Cause Having more than 1 dataReader result set working at the same time . Solution In my solution example, I work with Sql Server 2000 and VB.Net 2005 The VB. Net Example Project can be downloaded at the end of this post It contains (Sql Server 2000 DataBase - VB.Net Project) The example shows how to : Navigate (First Record - Next Record) using ADO Net 2.0 Online-Mode using SqlClient DataReader ... Sql Database Name : Market Sql Database Table : Market.Info Server Name : evry1falls (in order to see the example correctly, you'll have to Import the Database 'Market' into your sql server 2000 Enterprise Manager) Photo1 : Applica...