Solved

Invalid procedure call or argument: 'AscB'

Posted on 2003-12-10
9
971 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
  • 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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/…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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