- Create an ADODB connection object which is required step for connecting to database as below.
Create Recordset object which is for getting a value from database.
Authentication using Id, Password and details.
-
- Provider: For SQL server database the provider is “sqloledb”
- Server: Open the SQL Server in your machine and Right click on the required Database/ click on properties.
- Click on “View connection Properties”
- User Name and Server details are required from this dialogue box
- objConnection.open “provider=sqloledb; Server=SDWA-160-PC; User Id=SDWA-160; Password=; Database=sample; Trusted_Connection=Yes”
- Hence, Connection setup completed and ready for execution.
- Enter the required SQL query to be executed.
- Execution of the query with the statement below.
- The above mentioned sample script has been executed and the value from the database is retrieved.