Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
can you please share the qvw please
You do not need the QVW, you simply need to copy/paste the macro code into the Edit Module...
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