Results 1 to 6 of 6

Thread: What class should i import in order to use ADODB.Stream

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    39

    What class should i import in order to use ADODB.Stream

    Hi..
    I want transfer a image from my excel spreadsheet to a web server and i have written a web services so that it accepts a filename and then dumps it into web server.. if i just called that code in vb it works fine... but when i run the service it doesnt work.. this is the error that i am getting

    System.Web.HttpException: The component 'ADODB.STREAM' cannot be created. Apartment threaded components can only be created on pages with an <%@ Page aspcompat=true %> page directive.
    at System.Web.Util.AspCompatApplicationStep.CheckThreadingModel(String progidDisplayName, Guid clsid)
    at System.Web.HttpServerUtility.CreateObject(String progID)
    at MyService.Service1.getFileBytes(String flnm, String stype) in C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\MyService\MyService\Service1.asmx.vb:line 31
    at MyService.Service1.Sendit(String sFilename, String Stype) in C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\MyService\MyService\Service1.asmx.vb:line 21
    at MyService.Service1.UploadFile(String Filename, String sType) in C:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\MyService\MyService\Service1.asmx.vb:line 16


    and this is my code
    Code:
    Public Function getFileBytes(ByVal flnm As String, ByVal stype As String)
            Dim objstream As Object
            objstream = Server.CreateObject("ADODB.STREAM")
            If stype = "on" Then
                objstream = 1
            End If
            objstream.open()
            objstream.LoadFromFile(flnm)
    
            If stype = "on" Then
                getFileBytes = objstream.Read
            Else
                getFileBytes = objstream.ReadText
            End If
            objstream.Close()
            objstream = Nothing
    
    
        End Function
    Any help will be appreciated..
    Thanks,
    Karen

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: What class should i import in order to use ADODB.Stream

    are you doing this in

    VB.NET
    VB6
    VBA in Excel

    ??

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    39

    Re: What class should i import in order to use ADODB.Stream

    I am doing this in VB.NET
    Last edited by karenros; Dec 17th, 2008 at 03:46 PM.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: What class should i import in order to use ADODB.Stream

    Sorrry, I think I misread, from the error message, it looks to me you are using VS2005.

    I think the actual REASON for the exception is outlined pretty clearly though:

    The component 'ADODB.STREAM' cannot be created. Apartment threaded components can only be created on pages with an <@ Page aspcompat=true> page directive.

    ADODB is an old COM object from old ADO. If you are using .NET, it may be easier to use the actual built in ADO.NET data classes.

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: What class should i import in order to use ADODB.Stream


  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    39

    Re: What class should i import in order to use ADODB.Stream

    But i am using the ADODB.Stream in a Webservice and i am getting an error that says
    Attribute Page is not a valid element of webservice... and the aspCompat attribute is not supported by the Page attribute...
    this is what i have done in my .asmx page

    Code:
    <%@ WebService Language="VB" CodeBehind="Service1.asmx.vb" Class="MyService.Service1" %>
    <%@ Page AspCompat = "true"  Language ="VB" %>

    Thanks,
    Karen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width