Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Can�t seem to insert uploaded files into SQL table using feature pack file upload UD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can�t seem to insert uploaded files into SQL table using feature pack file upload UD

    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:

    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
    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.

    #2
    Re: Can�t seem to insert uploaded files into SQL table using feature pack file upload

    Originally posted by Maroine81 View Post
    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.
    add error checking to cn.open and cn.Execute to see if an sql error is being reported. if an error is reported use cn.callresult.text to access details.
    https://appsbydesign.co.uk/

    Comment


      #3
      Re: Can�t seem to insert uploaded files into SQL table using feature pack file upload

      thanks for your comment, I appreciate it. I'll try to do that. I have also been trying to get around an error on the grid that doesn't allow me to use the debugger to see exactly what's happening at each line of code ... I am sure I'll get to the source of the error once that is fixed.

      Comment


        #4
        Re: Can�t seem to insert uploaded files into SQL table using feature pack file upload

        I seem to remember that the grid need to be refreshed in thew video you are referring, so maybe this statement need to be uncommented
        'e.javascript ="window.parent.{grid.object}.refreshLinkedContent();"

        Comment


          #5
          Re: Can�t seem to insert uploaded files into SQL table using feature pack file upload

          Thank you Jim for your input...i forgot about that.
          The reason i was unable to debug was due to a session variable that the grid needed to have it passed to filter records so i removed it and the grid run in working preview mode with debug(1) on.
          then on the debugger, the cn.open(cs) was not executed at first so i put flag = cn.open(cs) then it returned true
          after that flag = cn.Execute(sql,args) was not executed so I thought it didn't recognize it then I added cn.PortableSQLEnabled=.T. after opening the connection and it worked like a charm.
          it's a wonderful feeling when the code works after spending so much time debugging it :)
          thank you again both for your input and hope that other A5ers will find this post useful.

          Comment


            #6
            Re: Can�t seem to insert uploaded files into SQL table using feature pack file upload

            hi
            i dont have a file uploader in my alpha
            can i get a grid with file uploader storing the blob values in sql for reference
            ill be grateful if you help me
            thanks anywayz!!

            Comment

            Working...
            X