These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

ADBC statement.execute displays different characters.

sirish_shrestha
Registered: Dec 7 2009
Posts: 12
Answered

I have a database with all the staff's information for our fax system in our department. The pdf plugin will do a certain thing that's necessary to send and receive fax as they come attached to our email in pdf format. Currently, all the staff's information is hard coded to the program so that the fax has annotation with the user's name and id number. Instead of hard coding I want to pull the necessary information from the database and annotate the fax (pdf document). The JavaScript is just a trial but it's not doing what it's supposed to. Here's the script -
 
//=========================================================================
try
{
var Connect = ADBC.newConnection("database","user","password");
if(Connect == null) {app.alert("Could not connect");}
else{app.alert("Database connected..");}
 
var statement = Connect.newStatement();
if(statement == null) throw "Could not execute newStatement";

var execStr = "Select first, second, third, fourth, fifth, sixth from table" ;

if(statement.execute(execStr)) throw "Could not execute the requested SQL";
statement.nextRow();
var row = statement.getRow();
console.println(row.first.value);

}
catch(e) {
app.alert("Error!" + e);
}
//======================================================================
It connects and doesn't throw me any error but it prints some different characters in the console window. The character looks likes this 獳慭汬. And it's different for different rows. I'm currently using Acrobat 9 Pro and I have already modified Registry to "activate" ADBC connection.
 
Thank you for your help.
 
Sirish

Sirish

My Product Information:
Acrobat Pro 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The code looks ok, and since it's connecting and returning a statement object it seems your DB is hooked up properly. However, the statement.execute() function does not return a value, so having it in a "if" does nothing, although this shouldn't affect your code.

The problem is probably with the data being returned, looks like it's binary. Could be a problem with how data is translated. Check the formatting in the DB. Is it Unicode?

I would suggest that you run your code line by line from the Console window. Look at the column info object to see what the data types are and check the all the column names and values returned to make sure what you want is what you are getting.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

sirish_shrestha
Registered: Dec 7 2009
Posts: 12
Thom,

You're right. It works now, Thanks for your help.


Sirish