Обо всём, что мне интересно
Получние данных для Excel с помощью запроса к базе данных
Если, например, требуется получить одно единственное значение с помощью запроса к базе данных (сам запрос может иметь заранее заданную конструкцию, меняющуюся в зависимости от определённых условий), то пригодится следующией код.
Для MS SQL
Sub Get_MSSQL_Data() Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sqlStr As String Set rs = CreateObject(«ADODB.Recordset») Set db = New ADODB.Connection db.Open _ «DRIVER=
Для других баз данных нужно изменить строку подключения:
I am facing a strange error while connecting Access DB using VBA. The VBA code goes like this:
The error it is giving is: «Compile Error: User define type not defined» and it is pointing to first line of the sub.
My table is present in the DB. It structures as follows:
Can anyone please help me with the reason why it is not accepting the ADODB and how to resolve this?
While I was try trying to query some data from SQL Server 2005 in Excel VBA Macro I get an error:
To fix this problem I just need to add a reference to the project. Here’s how:
1. Click on Tools.
2. Click on References. .
3. Ensure you have Microsoft ActiveX Data Objects selected.
Now try to run your Macro again and you should not encouter the error.