[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Invalid procedure call or argument: 'AscB'

Posted on 2003-12-10
9
Medium Priority
?
1,003 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

830 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