Dear community,
The files are uploaded successfully to the server specified folder but are not inserted into the SQL PROJ_FILES table, which has a parent table PROJECT. The button is in a grid associated with the project table and the row has already a PROJ_ID (GUID) assigned to it before upload.
I followed the instructions used in these videos (User Defined Advanced Examples) http://news.alphasoftware.com/V10Pre...ileUpload.html
I missing something, here is the screenshots Files_Upload_ss.png
Here is the XBasic function I am using:
All i want to do is to be able to see those files added to the PROJ_FILES table in SQL management studio after upload is done.
Thanks your help is very much appreciated.
The files are uploaded successfully to the server specified folder but are not inserted into the SQL PROJ_FILES table, which has a parent table PROJECT. The button is in a grid associated with the project table and the row has already a PROJ_ID (GUID) assigned to it before upload.
I followed the instructions used in these videos (User Defined Advanced Examples) http://news.alphasoftware.com/V10Pre...ileUpload.html
I missing something, here is the screenshots Files_Upload_ss.png
Here is the XBasic function I am using:
Code:
function saveFiles as v (e as p) dim count as n count = e.filecount dim i as n dim arr as p arr = e.filearray dim cn as sql::connection dim cs as c cs = e.tmpl.cs.ConnectionString cn.open(cs) dim sql as c sql = "insert into FILE (PROJ_ID, FILE_NAME) values (:projpk, :filename)" dim args as sql::arguments args.add("projpk",e.primaryKeyArray[1]) for i =1 to count dim fn as c dim data as b data = e.fileArray[i].data fn = "D:\Alpha5\A5Webroot\Projects\Proj_Files" + chr(92) + e.fileArray[i].fileName file.From_blob(fn,data) dim fntoStore as c fntoStore = e.fileArray[i].fileName args.add("filename",fntoStore) dim flag as l flag = cn.Execute(sql,args) next i cn.Close() 'e.javascript ="window.parent.{grid.object}.refreshLinkedContent();" 'This function is called after the file(s) selected in the Upload Files dialog have been uploaded to the server. 'The function is responsible for processing each uploaded file. 'The passed in 'e' object contains these properties 'e.fileCount - the number of files that were uploaded 'e.fileArray - a property array with one entry for each uploaded file 'e.uploadProperties - Contains multiple sub-properties for all of the properties set in the Action builder. 'e.rv - Request variables 'e.tmpl - pointer to the Grid definition 'e.rtc - a pointer variable that contains run-time calculations 'e.__si - state information 'e.session - session variables 'e.rowNumber - row number of the Grid row that has focus. If val(e.rowNumber) < 0, then it is a new record row. 'e.part - either 'G' (for 'Grid') or 'D' (for 'DetailView'). Test left(e.part,1) = "D" .or left(e.part,1) = "G" 'e.primaryKeyArray - an array of primary key values for the current row's primary key. If the primary key is based on a single field (or record number in the case of a .dbf table), the array will have one entry. If the primary key comprises multiple columns, the array will have an entry for each column in the primary key. 'e._isLinkedGrid - .t. if the Grid is a linked Grid (i.e. it has a parent Grid) 'e._linkValues = linking value. Contains a CRLF delimited list of linking values in this format: fieldname|type|linkingValue 'Each entry in the e.fileArray array has these propeties (where 'i' is between 1 and e.fileCount): 'e.fileArray[i].file.characterSet - character set of the uploaded file 'e.fileArray[i].file.contentType - MIME type (e.g. 'application/octet-stream') 'e.fileArray[i].data - data that was uploaded. This will either be binary data or text data. Check the .file.dataType property 'e.fileArray[i].fileName - filename of the file on the client machine 'e.fileArray[i].encoding - For text files, specifies the encoding type 'e.fileArray[i].file.dataType = Either 'text' or 'binary' 'If you want to send any Javascript back to the browser to execute after this event has completed, you can set this property: 'e.javascript 'EXTREMELY IMPORTANT - The Javascript that is sent back to the browser is executed in the context of the IFrame that contains the File Select window. 'Therefore, in order for the Javascript you send back to invoke methods of the Grid object, you must prefix all methods with 'window.parent'. 'For example: window.parent.{grid.object}.refresh() 'You can set e.abort = .t. to abort the operation. If you set e.abort to .t. then you can set e.errorText to the text you want to display to the user. end function
Thanks your help is very much appreciated.
Comment