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

Inserting data into a database

Hy!

I would like to know, if there is a possibility to insert a new record (data) into existing database through some kind of a form in Qlikview Sheet (I am connected to the Access DB)?

So, I would like to create a form in Qlikview Sheet (with data fields in which I could enter desired values) and then when I would click on button insert, this record would be inserted into my database that I'm connected to through Qlickview...

Please help me, thanks!

11 Replies
tseebach
Luminary Alumni
Luminary Alumni

In principle yes, but its not an recommendable solution.

Here are the basic steps:

  1. Read out your data from the source, mark all the fields you want a user to be able to edit as inputfields. Add some empty lines by making an inline table. You need to figure out a way to do get the right ID's for the database.
  2. Enter input fields values, and save these into a csv file.
  3. Reload and read in the csv file, but only the added lines. Then count the records and loop them all while you execute SQL INSERTS against your source.
  4. Reread the source, reset all input fields, add some new ones line in step 1.

I'd very much recommend, you to write a simple popup html widget that can be opened from qlikview and that has the input form you look for. From an architectural view I'd recommend that solution.

QlikView also has no good functions for validating input.

sparur
Specialist II
Specialist II

Hello.


Yes it's possible. But it's not a usual task for QlikView. Qlikview it's a tool for analyzing information.

But if you want it, you can create a VBScript macro, in which create a connection to your database and insert new rows. How do it? You can to use ADO connection, for example. You find more details in VBScript documentation.

Not applicable
Author

I'm totally lost... How do I read out my data from data source, mark all the fields I want,... Where can I do that?

prabhu0505
Specialist
Specialist

Hi,

Combination of Input Box (for getting input), Button with Macro enabled (for executing query) and Reload statement(reloading for reflection)

I hope this will do for you.

Not applicable
Author


Saravana Prabhu wrote:
Hi,
Combination of Input Box (for getting input), Button with Macro enabled (for executing query) and Reload statement(reloading for reflection)
I hope this will do for you.
<div></div>


This is the most likable solution. Do You have any small example maybe, like tutorial/guide... please?

prabhu0505
Specialist
Specialist

Sample Code:











set




set



status1 = ActiveDocument.variables("Status") mySelections1 = doc.fields("Project_id").GetSelectedValues

sql_query =
"update Projects set Project_status='"&status1.getContent. String&"' where Project_id="&mySelections1.Item(0).Text


This code is for updating, cook it for insert.

prabhu0505
Specialist
Specialist

Sample Code:


set mySelections = doc.fields("[Project Name]").GetSelectedValues
set mySelections1 = doc.fields("Project_id").GetSelectedValues
sql_query = "update Projects set Project_status='"&status1.getContent.String&"' where Project_id="&mySelections1.Item(0).Text


This code is for update, cook it for insert.

Not applicable
Author

Where do I write this code? Thanks!

Not applicable
Author

What do I have to change in Your code? Project Name and Project:_ID? Everything else stay the same? mySelections and mySelections1 is right? What does Project_ID and Projects stands for?