Announcement

Collapse
No announcement yet.

Need SQL tools example BLOB field

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

  • Need SQL tools example BLOB field

    I'm using sql 2005 express and trying to get a blob and store it in a binary file.
    So far I'm getting nothing but space.
    My first try on Blob fields. It looks like I have to do direct binding, but not sure.

    I've tried 25000 for the Blob size since this field when saved to a file creates a standard .ini file where I would use GetPrivateProfileString etc to retrieve values. They store it as a blob so only authorized uses can change it.


    Code:
          SQL_Authorize %MY_SQLT_AUTHCODE
          WHILE SQL_Errorpending
            lresult& = Sql_ErrorNumber
            IF lresult& <> %SUCCESS_WITH_INFO AND lresult& <> 999000049 AND lresult& <> 999000038 THEN
              SQL_MsgBox SQL_ErrorQuickOne + $CRLF + STR$(lresult&), %MSGBOX_OK
              Sql_ErrorClearOne
            ELSE
              lresult& = Sql_ErrorClearOne
            END IF
          WEND
          SQL_Initialize 50, 50, 100, 3, 3, 0, 0, 0
          WHILE SQL_Errorpending
            lresult& = Sql_ErrorNumber
            IF lresult& <> %SUCCESS_WITH_INFO AND lresult& <> 999000049 AND lresult& <> 999000038 THEN
              SQL_MsgBox SQL_ErrorQuickOne + $CRLF + STR$(lresult&), %MSGBOX_OK
              Sql_ErrorClearOne
            ELSE
              lresult& = Sql_ErrorClearOne
            END IF
          WEND
          Open_Ok& = SQL_OpenDB("DSN=UHHS;Trusted_Connection=Yes") 'establish a connection 
          WHILE SQL_Errorpending
            lresult& = Sql_ErrorNumber
            IF lresult& <> %SUCCESS_WITH_INFO AND lresult& <> 999000049 AND lresult& <> 999000038 THEN
              SQL_MsgBox SQL_ErrorQuickOne + $CRLF + STR$(lresult&), %MSGBOX_OK
              Sql_ErrorClearOne 
              GOTO EJOB
            ELSE
              lresult& = Sql_ErrorClearOne
            END IF
          WEND
          strSQL$ = "select CODE,INFO from ashared where code = 'FSL4.ini'"
          Rec_Oper& = SQL_Stmt(%SQL_STMT_IMMEDIATE,strSQL$)  'returns -1 if no table present to get a count of records
          Fetch_Ok& = SQL_FetchResult(1,1,%NEXT_ROW)
          WHILE SQL_Errorpending
            lresult& = Sql_ErrorNumber
            IF lresult& <> %SUCCESS_WITH_INFO AND lresult& <> 999000049 AND lresult& <> 999000038 THEN
              SQL_MsgBox SQL_ErrorQuickOne + $CRLF + STR$(lresult&), %MSGBOX_OK
              Sql_ErrorClearOne 
              GOTO EJOB
            ELSE
              lresult& = Sql_ErrorClearOne
            END IF
          WEND 
          MSGBOX(STR$(SQL_ResColType(2))) 
          DIM BLOB AS STRING * 256
          lresult& = SQL_DirectBindCol(2,%SQL_LONGVARBINARY,VARPTR(BLOB),256)
          SResult& = SQL_ResColSize(2)
          msgbox("Direct binding " + str$(sresult&) + " " + str$(len(BLOB)))
          WHILE SQL_Errorpending
            lresult& = Sql_ErrorNumber
            IF lresult& <> %SUCCESS_WITH_INFO AND lresult& <> 999000049 AND lresult& <> 999000038 THEN
              SQL_MsgBox SQL_ErrorQuickOne + $CRLF + STR$(lresult&), %MSGBOX_OK
              Sql_ErrorClearOne 
              GOTO EJOB
            ELSE
              lresult& = Sql_ErrorClearOne
            END IF
          WEND 
          
          OPEN "FSL4.INI" FOR BINARY AS 1
            PUT$ 1,BLOB
          CLOSE 1
          msgbox(FNTRM$(SQL_ResultColumnStr(1,1,1)) + $CRLF + STR$(lResult&))
          GOTO EJOB
    Bob Mechler
    Last edited by BOB MECHLER; 7 Apr 2009, 01:42 PM.

  • #2
    Bob --

    Direct Binding isn't usually necessary. Have you checked out the sample programs that are provided with SQL Tools? If you installed SQL Tools in the default folder...

    \SQLTools\Samples\PB\ReadLongData.BAS

    -- Eric Pearson, Perfect Sync, Inc.
    "Not my circus, not my monkeys."

    Comment


    • #3
      Thanks Eric,

      On my install that program is not in \SQLTools\Samples\PB\ReadLongData.BAS but is in
      \SQLTools\Samples. My oversight.

      The date on my DLL is 7/18/2003. Is there an updated version?

      Bob Mechler

      Comment


      • #4
        Yes. Send an email to the address below and we'll get you fixed up.

        -- Eric
        "Not my circus, not my monkeys."

        Comment

        Working...
        X