Solved

Invalid procedure call or argument: 'AscB'

Posted on 2003-12-10
9
978 Views
Last Modified: 2011-09-20
Hi,
I have a BLOB data field in a mySQL table. The field name is IVRResponses. When I try to convert this binary data into string i get the following error:-

Invalid procedure call or argument: 'AscB'

The following is my code

Set statsanswered = Server.CreateObject("ADODB.Recordset")
statsanswered.ActiveConnection = MM_dsn1_STRING
statsanswered.Source = "SELECT IVRResponses FROM mortgage_ldstats  WHERE result = 'answered';"
statsanswered.CursorType = 0
statsanswered.CursorLocation = 2
statsanswered.LockType = 1
statsanswered.Open()

Do While Not statsanswered.EOF
      For Each stats In statsanswered.Fields
            For I = 1 To LenB(stats.value)
        S = S & Chr(AscB(MidB(stats.value, I, 1)))
            Next
            response.write(S)
      Next
      statsanswered.MoveNext
Loop


Thanks,
Harish
0
Comment
Question by:harish3699
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9914149
maybe its trying to convert a null value??

Try writing out the result step by step.. see if it returns any null values..

Cheers!!
0
 

Author Comment

by:harish3699
ID: 9914496
I think there are some null values for that field in the database. How can i get around this problem?

Thanks,
Harish
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9914556
Try....

Do While Not statsanswered.EOF
      For Each stats In statsanswered.Fields
          If stats.value<>""
           For I = 1 To LenB(stats.value)
      S = S & Chr(AscB(MidB(stats.value, I, 1)))
           Next
           response.write(S)
     Next
        End If
     statsanswered.MoveNext
Loop

Cheers!!
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:harish3699
ID: 9914929
I used your code but it still gives an Type Mismatch error at the following line

If stats.value<>""

Since the data is in binary form, i dont think we can use it in the if statement

Thanks,
Harish
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9916466
try..

If Not Isnull(stats.value) Then

Cheers!!
0
 
LVL 28

Expert Comment

by:sybe
ID: 9919061
What do you want? Write binary data from a BLOB to the browser??

Then use
<%Response.BinaryWrite oRS("yourBLOBfield")%>

If you want to convert Binary to String then the method you are using is very slow, especially for larger binaries. Better use this function:

Function RSBinaryToString(ByVal btBinary)
    Dim oRS, iLen
    Set oRS = Server.CreateObject("ADODB.Recordset")
    iLen = LenB(btBinary)
    If iLen > 0 Then
        oRS.Fields.Append "mBinary", 201, iLen
        oRS.Open
        oRS.AddNew
        oRS("mBinary").AppendChunk btBinary
        oRS.Update
        RSBinaryToString = oRS("mBinary").Value
        oRS.Close
    Else
        RSBinaryToString = ""
    End If
    Set oRS = Nothing
End Function


see also http://www.pstruh.cz/tips/detpg_read-write-binary-files.htm
0
 

Author Comment

by:harish3699
ID: 9923861
Hi sybe,
I want to convert the blob data into string. I tried your code but it is giving me an error -  Invalid character - in the following line

oRS.Fields.Append "mBinary", 201, iLen      
--------------------------------------------^

Some of the records for the blob column in the database contain null values. Is that causing the problem?

My code is as follows

Do While Not statsanswered.EOF
      For Each stats In statsanswered.Fields
            Dim oRS, iLen
            Set oRS = Server.CreateObject("ADODB.Recordset")
            iLen = LenB(stats.value)
            If iLen > 0 Then
                  oRS.Fields.Append "mBinary", 201, iLen       
                  oRS.Open
                  oRS.AddNew
                  oRS("mBinary").AppendChunk stats.value
                  oRS.Update
                  RSBinaryToString = oRS("mBinary").Value
                  oRS.Close
            Else       
                  RSBinaryToString = ""
            End If
            Set oRS = Nothing
            response.Write(RSBinaryToString)
      Next
      statsanswered.MoveNext
Loop

Thanks,
Harish
0
 
LVL 21

Accepted Solution

by:
ap_sajith earned 100 total points
ID: 9924697
As i told you.. Its the nulls that cause the problem. Did you try IsNull(stats.value) ?

Do While Not statsanswered.EOF
     For Each stats In statsanswered.Fields
          Dim oRS, iLen
          Set oRS = Server.CreateObject("ADODB.Recordset")
If IsNull(stats.value) And stats.value<>"" Then
          iLen = LenB(stats.value)
          If iLen > 0 Then
               oRS.Fields.Append "mBinary", 201, iLen        
               oRS.Open
               oRS.AddNew
               oRS("mBinary").AppendChunk stats.value
               oRS.Update
               RSBinaryToString = oRS("mBinary").Value
               oRS.Close
          Else        
               RSBinaryToString = ""
          End If
          Set oRS = Nothing
          response.Write(RSBinaryToString)
End If
     Next

     statsanswered.MoveNext
Loop

Cheers!!
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10244095
Hi,
Any Updates?. Do you need any further assistance with this?. Please close this question if no further assistance is needed.
If you need help closing this question, please refer to http://oldlook.experts-exchange.com/help/closing.jsp on how to close a question.

Cheers!!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question