CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    India
    Posts
    38

    retrieving data from a webservice

    Hi all,

    This is my first task with web services and quite new .NET.

    I tried a test webservice with "hello world" and "addnum" functions. When I tested them, they worked fine. Then in the same service I added webmethods which interact with database and returns me the output.

    When I execute these methods while testing, I'm getting "Page cannot be displayed" in browser.

    How to locate the problem? And what could be the problem?

    Please help.

    thanks
    -srinivas

  2. #2
    Join Date
    Aug 2004
    Posts
    24

    Re: retrieving data from a webservice

    If you are having problem in accesing local database.
    UserName and Password to access the database should be either windows authenticate or different username/Password.


    Settings->Control Panel->Administrative Tools->IIS
    IIS Dialog will open,
    Choose the server ( should be computer name if its local )
    Web sites->Default web sites
    Find the project you created
    Right click to properties
    Directory Security->Edit
    Uncheck the Anonymous

    Now your application should work with database.

    Take it easy
    Marker

  3. #3
    Join Date
    Jan 2004
    Location
    India
    Posts
    38

    Re: retrieving data from a webservice

    Hi Marker,

    thanks for your time. I have done the changes you suggested. But it did not work out.

    I'm using local database.

    Here is my code:

    Imports System.Web.Services
    Imports System.Data
    Imports System.Data.SqlClient
    <System.Web.Services.WebService(Namespace:="http://MyWebSerives/DataTest/Service1")> _
    Public Class Service1
    Inherits System.Web.Services.WebService

    #Region " Web Services Designer Generated Code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Web Services Designer.
    InitializeComponent()

    'Add your own initialization code after the InitializeComponent() call

    End Sub

    'Required by the Web Services Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Web Services Designer
    'It can be modified using the Web Services Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    components = New System.ComponentModel.Container
    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    'CODEGEN: This procedure is required by the Web Services Designer
    'Do not modify it using the code editor.
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    #End Region

    ' WEB SERVICE EXAMPLE
    ' The HelloWorld() example service returns the string Hello World.
    ' To build, uncomment the following lines then save and build the project.
    ' To test this web service, ensure that the .asmx file is the start page
    ' and press F5.
    '
    <WebMethod()> _
    Public Function HelloWorld() As String
    Return "Hello World"
    End Function
    <WebMethod()> Public Function GetData() As DataSet
    Dim SqlCon As New SqlConnection
    Dim constr As String
    constr = "Provider=SQLOLEDB.1;Password=manager;Persist Security Info=False;User ID=sa;Initial Catalog=TransAidDB;Data Source=soft"

    SqlCon.ConnectionString = constr
    Try
    SqlCon.Open()
    Dim sqlcmd As SqlDataAdapter
    sqlcmd = New SqlDataAdapter("select* from ratedetails", SqlCon)
    Dim aut As New DataSet
    sqlcmd.Fill(aut, "Ratedetails")
    Return aut
    Catch ex As System.Exception
    MsgBox(ex.Message)
    Finally
    SqlCon.Close()
    End Try
    End Function
    End Class

    And also please check the attachment for output.

    thanks
    -srinivas
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2005
    Posts
    5

    Re: retrieving data from a webservice

    Hi,
    I think you cannot use msgbox in asp.net and you are returning dataset in try block but if code gets any error in try block statement then it is showing a messagebox(which is invalid in asp.net) and it is not returing anyvalue. So please change your code.
    Regards,
    Prachi

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

Featured