• Create an ADODB connection object which is required step for connecting to database as below.
Set objConnection = CreateObject(“ADODB.Connection“)
Create Recordset object which is for getting a value from database.
Set objRecordSet = CreateObject(“ADODB.Recordset“)

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.
objRecordSet.open sqlQuery, objConnection
set conn=Createobject ("ADODB.Connection") 
Srvname="Driver={Microsoft ODBC for
Oracle}:Server=DBserver,UID=Sa,Password=sa"
conn.open Srvname
Set Rec = Create Object("ADODB.Recordset")
SQL="select * from Users"
Rec.open SQL ,conn
Username=Rec.fields("employee name")
Msgbox Username
  • The above mentioned sample script has been executed and the value from the database is retrieved.

Categorized in:

Tagged in:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,