?
Solved

Invalid procedure call or argument: 'AscB'

Posted on 2003-12-10
9
Medium Priority
?
991 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 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