(1) I have tried to set a transaction object so I can retrieve and display a blob in a data window. I am not sure what is going wrong with my code. Could some please tell me what I am doing wrong. The program keeps crashing at line 2:
SQLCB.DBMS="ODBC" //Error: empty sting
(2) Do I have to set up a second transaction object connect back to the database or will my program use the existing (previous) connection after I disconnect?
Any help would be appreciated.
Thank You,
rjoshi2
My Code :
transaction SQLCB
SQLCB.DBMS="ODBC"
SQLCB.DBParm="ConnectString='DSN=OracleOracleDSN;UID=as_userid;PWD=as_password'"
CONNECT USING SQLCB;
integer li_FileNum, loops, i
blob b_file_pic, b, tot_b
long ll_len, flen, bytes_read, new_pos, bytes_write
//The following example reads a blob from the database and writes it to a file.
//The SQL SELECT statement assigns the picture data to the blob Emp_Id_Pic.
//Then FileOpen opens a file for writing in stream mode and FileWrite writes the blob to the file.
//You could use the Len function to test whether the blob was too big (>32,765 bytes) for a single FileWrite call:
SELECTBLOB REPORT_PICTURE.RPICTURE
INTO :b_file_pic
FROM REPORT_PICTURE
WHERE REPORT_PICTURE.RNUMBER = 2
USING SQLCB;
IF SQLCB.SQLCODE = 0 THEN
// everything OK
li_FileNum = FileOpen( &
"C:\Documents and Settings\administrator\Desktop\testing.psr", &
StreamMode!, Write!, Shared!, Replace!)
//Get the length of the b_file_pic
flen = len(b_file_pic)
// Determine how many times to call FileWrite
IF flen > 32765 THEN
MessageBox("Lenght of the file is > then 32,765 bytes. It is ", flen)
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF
// Write the file
new_pos = 1
FOR i = 1 to loops
bytes_write = FileWrite(li_FileNum, b_file_pic)
tot_b = tot_b + b_file_pic
NEXT
//This example reads a file exceeding 32,765 bytes.
//After the script has read the file into the blob tot_b, you can call the SetPicture or
//String function to make use of the data, depending on the contents of the file:
//Get the file length, and open the file
flen = FileLength("C:\Documents and Settings\administrator\Desktop\testing.psr"
li_FileNum = FileOpen("C:\Documents and Settings\administrator\Desktop\testing.psr", &
StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF flen > 32765 THEN
MessageBox("Lenght of the file is > then 32,765 bytes. It is ", flen)
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b
NEXT
FileClose(li_FileNum)
dw_1.DataObject = "C:\Documents and Settings\administrator\Desktop\testing.psr"
ELSE
MessageBox("Connection Error", "Please contact your computer Administrator."

END IF
DISCONNECT USING SQLCB;