Web Service returning dataset - invalid data src


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Web Service returning dataset - invalid data src

  1. #1
    Join Date
    Aug 2005
    Posts
    79

    Question Web Service returning dataset - invalid data src

    This is my first attempt at using Web Services, and I've tested the actual web service which works via the Invoke button.

    I'm getting the following error when trying to build a ddl from my web service dataset:
    An invalid data source is being used for DropDownList1. A valid data source must implement either IListSource or IEnumerable.

    The WebReference for the web service is called GetWBS.

    The code for the calling page is:
    **************************
    **************************

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    'Create an instance of the Proxy class
    Dim dsGetWBS As GetWBS.WBSValues
    dsGetWBS = New GetWBS.WBSValues

    DropDownList1.DataSource = dsGetWBS
    DropDownList1.DataBind()
    End Sub


    I've added a Web Reference, GetWBS, and the code for the .asmx file is:
    ************************************************************
    ************************************************************
    Public Class WBSValues
    <WebMethod()> _
    Public Function GetWBS() As DataSet
    Dim DS As New DataSet
    Try
    sCon1.Open()
    Dim strSQLType As String = "usp_SelectWBSNumberFromWBSDict"
    Dim cmd As New SqlCommand(strSQLType, sCon1)
    cmd.CommandType = CommandType.StoredProcedure
    'Create the DataAdapter
    Dim DA As New SqlDataAdapter
    DA.SelectCommand = cmd
    'Populate the DataSet and the connection
    DA.Fill(DS, "WBSDict")
    sCon1.Close()
    Return DS
    Catch ex As Exception
    Throw ex ' = "Error Line 2928 Getting Types for SigAuth Datagrid: " & ex.Message
    Finally
    sCon1.Close()
    End Try
    End Function
    End Class

  2. #2
    Join Date
    Aug 2005
    Posts
    79
    I had to change this in the code behind for the calling page:
    'Create an instance of the Proxy class
    Dim dsGetWBS As GetWBS.WBSValues
    dsGetWBS = New GetWBS.WBSValues

    DropDownList1.DataSource = dsGetWBS.GetWBS
    DropDownList1.DataTextField = Expr1
    DropDownList1.DataValueField = [WBS Number]
    DropDownList1.DataBind()

    ..but now, the DataTextField and the DataValueField are not right:
    DropDownList1.DataTextField = Expr1 'Expr1 Not declared
    DropDownList1.DataValueField = [IDNumber] 'Expression Expected


    If I just do this for the code behind:
    ***
    ***
    Dim dsGetWBS As GetWBS.WBSValues
    dsGetWBS = New GetWBS.WBSValues

    DropDownList1.DataSource = dsGetWBS.GetWBS
    DropDownList1.DataBind()

    ...the code works, but the ddl says System.Data.DataRowView for each row

  3. #3
    Join Date
    Aug 2005
    Posts
    79
    It would help if I put the "" around the values for the dataTextField and the DataValuefield, and from my original coce added ".Tables(0)" to the datasource.

    I've used the following code and now have it working:

    'Put user code to initialize the page here
    'Create an instance of the Proxy class
    Dim dsGetWBS As GetWBS.WBSValues
    dsGetWBS = New GetWBS.WBSValues

    DropDownList1.DataSource = dsGetWBS.GetWBS.Tables(0)
    DropDownList1.DataTextField = "Expr1"
    DropDownList1.DataValueField = "WBS Number"
    DropDownList1.DataBind()

Similar Threads

  1. web service to store data in XML file
    By raewyn in forum XML
    Replies: 1
    Last Post: 11-28-2005, 04:07 PM
  2. Replies: 0
    Last Post: 05-01-2003, 05:42 PM
  3. Can a Delegate be passed to a Web Service?
    By Steve Hiner in forum .NET
    Replies: 7
    Last Post: 04-22-2002, 09:19 PM
  4. Access data from a web page
    By Jawahar Rajan in forum Enterprise
    Replies: 0
    Last Post: 06-13-2001, 09:50 AM
  5. web service authentication mechanisms
    By Dan Davis in forum .NET
    Replies: 0
    Last Post: 05-16-2001, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center