Problem with a DataSet

A

André Giesing

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?
 
S

Somchai U.

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

Somchai
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top