Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VB

How to connect with different types of DataBase?

2.73/5 (9 votes)
25 Nov 2011CPOL 29K  

Introduction


While developing Ado.Net Applicaions most of the errors comes because of the wrong format of Connection String used to connect the application with the DataBase. I am publishing some Connection String formats to connect with different types of DataBase.

Connection String Formats


To connect with the Ms-Access 2003 DataBase Connection String Format:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Full Path of the DataBase File with Extension (".Mdb");Persist Security Info=True;Jet OLEDB:Database Password=********"

To connect with the Ms-Access 2007 DataBase Connection String Format:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Full Path of the DataBase File with Extension (".accdb");Persist Security Info=True;Jet OLEDB:Database Password=********"

To connect with the SQL Server DataBase Connection String Format:
"DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DataBaseName.mdf;
Integrated Security=True;User Instance=True"

To connect with the MYSQL DataBase Connection String Format:
"DataSource=Sever Name;DataBaseName=DataBase File Name;
UserName="Name";Password=*******"

I hope this will help New developers in ADO.Net Programming.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)