In Visual Basic 2015, we need to create a connection to a database before we can access its data. Before we begin, let’s create a new database. Since we are using SQL Server 2012 as the database engine, we will use Microsoft Studio Management Express to create a database with the mdf extension. We shall name this database file as test.mdf.
After creating the database, build a table called Contacts and create two fields and name them ContactName and State respectively. Enter a few data in the table and click Save All to save the data. Now we are ready to connect to this new database.ADO.NET offers a number of connection objects such as OleDbConnection, SqlConnection and more. OleDbConnection is used to access OLEDB data such as Microsoft Access whilst SqlCOnnection is used to access data provided by Microsoft SQL Server. Since we will work with SQL database in our example, we will use the SqlConnection object.
To learn how to connect a database , we suggest you grab a copy of Visual Basic 2015 Made Easy.
AUTHOR: DR. LIEW VOON KIONGVisual Basic 2015 Made Easy is written by Dr. Liew, the webmaster of our popular online Visual Basic Tutorial, vbtutor.net. This book is a complete guide to mastering Visual Basic 2015, from beginner to intermediate programmers. This book has been written to complement our free online Visual Basic 2015 tutorial with much more content. It is also an excellent reference text for high school or college-level computer science courses. Reading this book will allow you to:
This site and the products and services offered on this site are not associated, affiliated, endorsed, or sponsored by Microsoft, nor have they been reviewed tested or certified by Microsoft.
If you require assistant and technical support, please email