Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello.
I have a vbscript module that inserts values in an oracle table.
sub oracle
set db = CreateObject("ADODB.Connection")
db.open "DSN=XXX;UID=XXX;PWD=XXX"
set Orderfile = db.execute("INSERT INTO QLIKVIEW (STORE, SALES) VALUES ('101', '42000');")
set Orderfile = db.execute("COMMIT;")
db.Close
end sub
It is working correct and inserts the values into the oracle table.
How can i insert values from an input box with variables into the oracle table ?
Let's say i create a variable $(STORE) and $(SALES)
How can i read the variables and insert the values into the oracle table ?
I attach a file.
Perhaps something like this:
sub oracle
set db = CreateObject("ADODB.Connection")
db.open "DSN=XXX;UID=XXX;PWD=XXX"
myStore = ActiveDocument.Variables("vStore").GetContent.String
mySales = ActiveDocument.Variables("vSales").GetContent.String
strSQL = "INSERT INTO QLIKVIEW (STORE, SALES) VALUES (' " & myStore &" ', ' " & mySales & " ');"
set Orderfile = db.execute(strSQL)
set Orderfile = db.execute("COMMIT;")
db.Close
end sub
I have problem in this line
myStore = ActiveDocument.Variables("vStore").GetContent.String)
It returns the message because of the )
Expected end of statement
Yeah, cut&paste error. Remove the last ) from both those lines.
No does not pass when i try to run the module. It is stop in the line
mySales = ActiveDocument.Variables("SALES").GetContent.String
Try if you can get echo the value of your variable at all:
Sub CheckVariable
SET vCheck = ActiveDocument.Variables("STORE")
MsgBox(vCheck.GetContent.String)
End Sub
It returns the correct value but when i give the following commands does not work
sub oracle
set myStore = ActiveDocument.Variables("STORE")
myStore.GetContent.String
set db = CreateObject("ADODB.Connection")
db.open "DSN=xxx;UID=xxx;PWD=xxx"
set Orderfile = db.execute("INSERT INTO QLIKVIEW3 (STORE) VALUES ('"&myStore&"');")
set Orderfile = db.execute("COMMIT;")
db.Close
end sub
myStore.GetContent.String <- doesn't do anything
Perhaps this works:
sub oracle
set vVar = ActiveDocument.Variables("STORE")
myStore = vVar.GetContent.String
set db = CreateObject("ADODB.Connection")
db.open "DSN=xxx;UID=xxx;PWD=xxx"
set Orderfile = db.execute("INSERT INTO QLIKVIEW3 (STORE) VALUES ('" & myStore & "');")
set Orderfile = db.execute("COMMIT;")
db.Close
end sub
Unfortunately does not pass.
Maybe the problem is in line
set Orderfile = db.execute("INSERT INTO QLIKVIEW3 (STORE) VALUES (' " & myStore &" ');")
and can not recognize the variable.