Solved

Invalid procedure call or argument: 'AscB'

Posted on 2003-12-10
9
964 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
 

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now