wcf返回datatable必须给tablename赋值
生活随笔
收集整理的這篇文章主要介紹了
wcf返回datatable必须给tablename赋值
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
最近在學(xué)習(xí)WCF,返回datatable的時(shí)候老是出現(xiàn)“An error occurred while receiving the HTTP response to http://localhost:9999/calculatorservice. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.”的錯(cuò)誤。檢查了半天才發(fā)現(xiàn)原來(lái)是返回的datatable沒(méi)有給tablename賦值。
?
代碼 public?System.Data.DataTable?GetDataTable()????????{
????????????DataTable?mydt?=?new?DataTable();
????????????mydt.Columns.Add("UserID",?typeof(int));
????????????mydt.Columns.Add("UserName",?typeof(string));
????????????mydt.Columns.Add("Birthday",?typeof(DateTime));
????????????for?(int?i?=?0;?i?<?300;?i++)
????????????{
????????????????DataRow?dr?=?mydt.NewRow();
????????????????dr["UserID"]?=?i?+?1;
????????????????dr["UserName"]?=?"xx"?+?i;
????????????????dr["Birthday"]?=?DateTime.Now;
????????????????mydt.Rows.Add(dr);
????????????}
????????????return?mydt;
????????}
?
?后來(lái)加上mydt.TableName="mydt";就好了。
轉(zhuǎn)載于:https://www.cnblogs.com/hxw/archive/2010/07/10/1774841.html
總結(jié)
以上是生活随笔為你收集整理的wcf返回datatable必须给tablename赋值的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: dropbox解决办法
- 下一篇: Cisco端口特性