Institute Name - Expert Tutorial, Creator Name - Himanshu Sachan
Hi, In this video you can Fetch data from SQL Server by VBA Coding but Need to activate the library of ADO - Active Data Object in Visual Basic Application.
Library Name - Microsoft Active Data Object (ADO)
Code :
Sub SQL_CN()
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
cn.Open "driver=SQL Server;server=DESKTOP-FF5VHA0;database=Himanshu"
rs.Open "select * from Customere_ID", cn, adOpenStatic
Range("a1").CopyFromRecordset rs
rs.Close
cn.Close
End Sub
Thank you to visit my channel, If you are having any query or want to Join our Live session, Please whats app me or call on +91-9555276018