Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jmvilaplanap
Specialist
Specialist

Connection String in Macro

Hi all,

I'm trying to call a SQL Server Stored Procedure from Qlikview Macro, but It's impossible to connect to the database. I copy and paste the same connection string that I have in the "regular" script but didn't work, I tried to create an ODBC Connection and didn't work, I tried a lot of things but I can't connect.

Has anyone tried to connect to a database from a macro?

I've tried with the answers of naveenvyas1 in from this discussion: Call a Stored Proc behind a button

Thank you very much.

1 Solution

Accepted Solutions
jmvilaplanap
Specialist
Specialist
Author

Hi jmvilaplanap

I'm you in the future (well, really you are me in the past),

It's done, it was not so difficult, it didn't work because you was not using the right objects.

Here you have an example:

Dim objCommand

Dim objField

Dim objRecordSet

Dim rowsExported

Dim rowsOriginal

Set objConnection = CreateObject("adodb.connection")

Set objCommand= CreateObject("adodb.command")

Set objRecordSet= CreateObject("ADODB.RECORDSET")

objConnection.Open "Provider=sqloledb;Data Source=dev-sql-int04;Initial Catalog=db;User Id=usr;Password=pass;"

objCommand.CommandText = "SELECT count(*) FROM table"

Best Regards

View solution in original post

2 Replies
jmvilaplanap
Specialist
Specialist
Author

Hi jmvilaplanap

I'm you in the future (well, really you are me in the past),

It's done, it was not so difficult, it didn't work because you was not using the right objects.

Here you have an example:

Dim objCommand

Dim objField

Dim objRecordSet

Dim rowsExported

Dim rowsOriginal

Set objConnection = CreateObject("adodb.connection")

Set objCommand= CreateObject("adodb.command")

Set objRecordSet= CreateObject("ADODB.RECORDSET")

objConnection.Open "Provider=sqloledb;Data Source=dev-sql-int04;Initial Catalog=db;User Id=usr;Password=pass;"

objCommand.CommandText = "SELECT count(*) FROM table"

Best Regards

chetanpatel
Contributor III
Contributor III

Hi  is it working  Script