Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
The #1 reason QlikView customers adopt Qlik Sense is a desire for a modern BI experience. Read More
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

Writing back from qlikview to sql

HI all,

I have requirement in QlikView

in the access point , there will be 3 buttons(yes) button, (NO) button   and submit button.

I have created a table in the sql with columns

ID, UserName,Userchoice(this will be yes or No) and updated date .

Now if the user clicks on the Yes button  or No button and click on submit button, it needs to get feeded in the database . can anyone please help me as it is very uregent.

 

 
Labels (1)
3 Replies
Highlighted
Partner
Partner

Re: Writing back from qlikview to sql

Hi!

You can build a macro to create an ODBC/OLEDB connection to the data base and write or update rows. This is not recommended in general but here you have a sample code that I built in QV desktop to test this feature:

sub test

i_NuevoDepartamento = ActiveDocument.Variables("vNuevoDepartamento").getcontent.string
i_NuevaDescripcion = ActiveDocument.Variables("vNuevoDescDepartamento").getcontent.string

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Test_SQLS;"

strSQL_MaxID = "SELECT MAX ([DepartmentID]) as UltimoID FROM [AdventureWorks2017].[HumanResources].[Department]"

objRecordset.CursorLocation = 3
objRecordset.Open strSQL_MaxID, objConnection, 3, 3
objRecordSet.MoveFirst

strSQL_INSERT = "INSERT into [AdventureWorks2017].[HumanResources].[Department] ([Name],[GroupName]) VALUES ("
strSQL_INSERT = strSQL_INSERT & chr(39) & i_NuevoDepartamento & chr(39) & ","
strSQL_INSERT = strSQL_INSERT & chr(39) & i_NuevaDescripcion & chr(39) & ")"

msgbox(strSQL_INSERT)

objConnection.Execute(strSQL_INSERT)

objRecordset.Close
objConnection.Close

end sub

Regards,

Jaime.

Highlighted
Creator
Creator

Re: Writing back from qlikview to sql

can you please share the qvw please

Highlighted
Digital Support
Digital Support

Re: Writing back from qlikview to sql

You do not need the QVW, you simply need to copy/paste the macro code into the Edit Module...

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Edit_Module2.ht...

Please be sure to mark the post as the solution once you can test things, I am guessing the code may need some tweaks to account for your environment info etc...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.