Problem with a DataSet

Discussion in 'ASP .Net Web Services' started by André Giesing, Sep 1, 2003.

  1. Hello!

    I've made a simple WebService, which connects to a Access Database
    selects everything out of the table "KUNDE" and gives it as a DataSet
    back.
    Here is the Code:

    [WebMethod]
    public DataSet GetKunden()
    {
    OleDbConnection con;
    OleDbDataAdapter da;
    OleDbCommand cmd;

    DataTable tbl = new DataTable("Kunde");
    DataSet ds = new DataSet("dsKunde");

    try
    {
    //*1* Verbindung herstellen
    con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
    + "Password=;User ID=;Data Source=;");

    //*2* Command-Objekt anlegen
    cmd = new OleDbCommand("SELECT * FROM KUNDE", con);

    //*3* DataAdapter anlegen und Tabelle füllen
    da = new OleDbDataAdapter(cmd);
    da.Fill(tbl);

    //*4* Tabelle dem DataSet hinzufügen
    ds.Tables.Add(tbl);

    //*5* DataSet zurückgeben
    return(ds);
    }
    catch(Exception ex)
    {
    return(null);
    }
    }

    In my little mobile Client I just want to get the Data and it should
    be displayed in a simple DataGrid.
    This is the Code I've made:

    private DataSet m_dsDaten = new DataSet();
    private void btnDatenHolen_Click(object sender, System.EventArgs e)
    {
    WebReference.Service ws = new WebReference.Service();

    try
    {
    //*1* Kundendaten laden
    m_dsDaten = ws.GetKunden();

    //*2* DataGrid an Tabelle binden
    dgKunden.DataSource = m_dsDaten.Tables["KUNDE"];
    }
    catch (Exception ex)
    {
    MessageBox.Show("Fehler in btnDatenHolen_Click: \n\n" +
    ex.ToString());
    }
    }

    But when I want to display the Data in my little mobile application
    (in a DataGrid), I get the following error:

    "System.InvalidOperationException:Server found request content type to
    be 'text/html; charset=utf-8' but expected 'text/xml'."

    Any ideas why I get this error?
     
    André Giesing, Sep 1, 2003
    #1
    1. Advertising

  2. André Giesing

    Somchai U. Guest

    The URL of web service may be incorrect (for example, it may point to
    localhost).

    Somchai

    "André Giesing" <> wrote in message
    news:...
    > Hello!
    >
    > I've made a simple WebService, which connects to a Access Database
    > selects everything out of the table "KUNDE" and gives it as a DataSet
    > back.
    > Here is the Code:
    >
    > [WebMethod]
    > public DataSet GetKunden()
    > {
    > OleDbConnection con;
    > OleDbDataAdapter da;
    > OleDbCommand cmd;
    >
    > DataTable tbl = new DataTable("Kunde");
    > DataSet ds = new DataSet("dsKunde");
    >
    > try
    > {
    > //*1* Verbindung herstellen
    > con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
    > + "Password=;User ID=;Data Source=;");
    >
    > //*2* Command-Objekt anlegen
    > cmd = new OleDbCommand("SELECT * FROM KUNDE", con);
    >
    > //*3* DataAdapter anlegen und Tabelle füllen
    > da = new OleDbDataAdapter(cmd);
    > da.Fill(tbl);
    >
    > //*4* Tabelle dem DataSet hinzufügen
    > ds.Tables.Add(tbl);
    >
    > //*5* DataSet zurückgeben
    > return(ds);
    > }
    > catch(Exception ex)
    > {
    > return(null);
    > }
    > }
    >
    > In my little mobile Client I just want to get the Data and it should
    > be displayed in a simple DataGrid.
    > This is the Code I've made:
    >
    > private DataSet m_dsDaten = new DataSet();
    > private void btnDatenHolen_Click(object sender, System.EventArgs e)
    > {
    > WebReference.Service ws = new WebReference.Service();
    >
    > try
    > {
    > //*1* Kundendaten laden
    > m_dsDaten = ws.GetKunden();
    >
    > //*2* DataGrid an Tabelle binden
    > dgKunden.DataSource = m_dsDaten.Tables["KUNDE"];
    > }
    > catch (Exception ex)
    > {
    > MessageBox.Show("Fehler in btnDatenHolen_Click: \n\n" +
    > ex.ToString());
    > }
    > }
    >
    > But when I want to display the Data in my little mobile application
    > (in a DataGrid), I get the following error:
    >
    > "System.InvalidOperationException:Server found request content type to
    > be 'text/html; charset=utf-8' but expected 'text/xml'."
    >
    > Any ideas why I get this error?
     
    Somchai U., Sep 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,839
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    558
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. Joseph D. DeJohn

    DataSet to DataSet

    Joseph D. DeJohn, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    429
  4. Nedu N
    Replies:
    2
    Views:
    2,209
  5. William Gower
    Replies:
    2
    Views:
    4,199
    Brian Baker [MVP]
    Jul 26, 2004
Loading...

Share This Page