Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
IMPORTANT: Upcoming LEF Database Maintenance, Oct. 3rd - SEE DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Specialist
Specialist

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

1 Reply
Highlighted
Specialist
Specialist

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