Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8543185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:14:33+00:00 2026-06-11T12:14:33+00:00

I am trying to retrieve a list of dropdown items from the database. The

  • 0

I am trying to retrieve a list of dropdown items from the database. The code works good if I am not using a Web Service to access the database, but when I used webservice to access the database, it gives me a Soap Exception. Here is the code, please help.

The Exception is:

System.Web.Services.Protocols.SoapException: Server was unable to process request. --->
System.InvalidOperationException: There was an error generating the XML document. --->
System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set.
    at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean writeHierarchy)

Here is the Method:

private void retrieveStates()
        {
            dataService = new PCDDA.Service();
            DataTable dt = new PCDDA.Service().GetStates();
            DDLSelectState.DataSource = dt;
            DDLSelectState.DataTextField = "RegionName";
            DDLSelectState.DataValueField = "RegionID";
            DDLSelectState.DataBind();
            DDLSelectState.Items.Insert(0, new ListItem("<Select State>", "0"));
        }

Here is the GetStates() Web Method which is in the Service.cs class of the Web Service:

[WebMethod]
    public DataTable GetStates()
    {
        DbPostcardOTR db = new DbPostcardOTR();
        try
        {
            DataTable loadstates = db.LoadStates();
            return loadstates;

        }
        catch (Exception ex)
        {
            throw new Exception("Unable to retrieve or load States from the database. The Exception is :" + ex.Message);
        }

    }

This is the LoadStates() Method in the DbPostcardOTR.cs:

 public DataTable LoadStates()
    {
        DataTable States = new DataTable();
        SqlConnection con = OpenConnection();
        try
        {
            string selectSQL = "Select RegionID, RegionName from PCDDev.dbo.tblDistributionArea";
            SqlCommand cmd = new SqlCommand(selectSQL, con);
            SqlDataReader dr = cmd.ExecuteReader();
            States.Load(dr);
            return States;
        }
        finally
        {
            if (con != null)
                con.Close();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:14:34+00:00Added an answer on June 11, 2026 at 12:14 pm

    From Microsoft:

    The DataTable, DataRow, DataView, and DataViewManager objects cannot
    be serialized and cannot be returned from an XML Web service. To
    return less than a complete DataSet, you must copy the data that you
    want to return to a new DataSet.

    Source: Problems using an XML Web service that returns a DataTable

    Note: The above source contains an alternative which may work in your situation. In a nutshell, return a DataSet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to retrieve a list of clients from the server (server using
I am trying to retrieve a list of images and text from a web
I'm trying to retrieve a list of events from a google calendar, using the
I'm trying to retrieve list data from a Sharepoint 2010 server using the webservice
I am trying to use SharePoint Web service to retrieve list changes but there
I am trying to retrieve from my database all posts and list them in
I have been trying to retrieve particular fields from my database using NHinernate. The
In my block code I am trying to programmatically retrieve a list of products
I'm trying to generate a list dynamically from database. The results can be retrieved,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.