Introduction
Databases are widely used in applications to keep records. A large variety of Database Management Systems are available in the market and in use. Every DBMS needs a different format of the connection string. It's not possible to remember all those formats, so knowing how to get a Connection String for any database makes life easy.
UDL file Method
UDL Files are an easy way to get the desired connection string by simply filling in property pages. The following steps show how to make and use a UDL file for that.
1. Make a New Text Document
2. Open the Text Document, Click on Save As
3. Write the filename as something.udl, file type All files, click Save.
4. Now run something.udl
5. Click on the Provider tab. Select the provider and click Next.
6. Give the DataBase Path
7. Write Username, Password if any
7. Click on Test Connection
8. If it's OK, then close it now
9. Now open udl file as Text File with Notepad
11. The Last line will have the Connection String
Visual Studio DataSource Method
1. Add DatagridView to your Form
2. Click on Arrow in the Top Right Corner of DataGridView, Click Choose DataSource, Select Add New DataSource
3. Select Database, and Click on Next
4. Click on New Connection
5. Now Choose DataSource, Click on Continue
6. Browse For the Database. Provide Username, Password, if any
7. Click On Test Connection
8. If all is Ok, Click Previous, Copy the Connection String, and Click Cancel, Delete DataGridView if you don't need it
Oracle Connection String
Following is the Correct Format of Oracle Database Connection
using Oracle.ManagedDataAccess.Client;
public void Execute(string queryString, string connectionString)
{
using (OracleConnection connection = new OracleConnection(connectionString))
{
OracleCommand command = new OracleCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
(For Detailed Study of Connection Strings)
Do suggest/Comment, Help Others