Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2004, 11:07 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default Return OleDb.OleDbConnection from the WEB method?

Hi,
I have the question:"How to return OleDb.OleDbConnection from the <WebMethod()>?" For example I have the <WebMethod()> like this:

Private myConnection As OleDb.OleDbConnection
<WebMethod()> _
    Public Function Get_DATAConnection() As Object
        If myConnection.State = ConnectionState.Open Then
            Return myConnection
        Else
            Return Nothing
        End If
    End Function
If I specify the return type as "OleDb.OleDbConnection" it gives me the compilation Error. If I specify as an "Object" the compilation is working but than I am having error using the returned type as an OleDb.OleDbConnection directly and same result if I try to cast the returned Object type into OleDb.OleDbConnection using CType.
Any suggestions?
Thanks Dmitriy :(
 
Old May 3rd, 2004, 05:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hmmm, I think you're trying to use a Web Service for a purpose it wasn't designed for.
Why on earth would you want a Web method that returns an OleDb connection?????

Within local scope a method that returns an (open) connection makes sense to me. But to a Web service? So what, I hit your Web service and get a connection I can execute SQL statements against?

Web Services usually return data. Usually, they do this in world readable XML streams, or, in the .NET world, a DataSet (which results in a readable XML stream for any non .NET client)

What is your intention with this method? Maybe there are other ways to accomplish the same thing....

Cheers,

Imar
 
Old May 4th, 2004, 07:10 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Imar,
Thanks for your reply. My guess was: "If WEB method can return an Object data type, so I can convert the returned Object to OleDb.OleDbConnection data type and use it after words". My application supposes to work with repeatedly growing number of databases and my intention was to keep all database-related operations inside the WEB service and do not mess with all connection’s stuff etc. inside my application. And everything is working OK except "connections" part.
Probably you right and I will do this locally.
Thanks again
       -Dmitriy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Return Collection object from a Web Method raybo .NET Web Services 2 June 17th, 2006 07:42 AM
Return a custom type from a web service gabrieldcr2 .NET Web Services 1 November 27th, 2005 01:26 PM
how to return binary from web service forkhead VB How-To 6 August 24th, 2005 07:44 AM
Incomplete Result from Web Method pearsonbe .NET Web Services 0 January 28th, 2005 10:34 AM
Return DataTable from Web Method Function kasie ASP.NET 1.0 and 1.1 Basics 2 February 11th, 2004 06:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.