ASP.NET中关于dataset的问题 10

以下是我的程序:usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Dat... 以下是我的程序:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class dataadpater : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet set=UseDataadpater();

}
public DataSet UseDataadpater()
{

SqlConnection myCon=new SqlConnection();
myCon.ConnectionString="Persist Security info=false; User id=sa;pwd=wxz;database=northwind;server=PC-200909061709";
myCon.Open();
SqlDataAdapter myAdpater=new SqlDataAdapter();
SqlCommand myCom=new SqlCommand();
myCom.Connection=myCon;
myCom.CommandText="select CustomerID,CompanyName from Customers";
myAdpater.SelectCommand=myCom;
DataSet mySet=new DataSet();
myAdpater.Fill(mySet,"Customers");

SqlCommand updata=new SqlCommand();
updata.Connection=myCon;
updata.CommandText = "update Customers set CompanyName='KFC' where CustomerID='ALFKI'";
myAdpater.UpdateCommand=updata;

myAdpater.Update(mySet);
myCon.Close();
return mySet;

}

protected void Button1_Click(object sender, EventArgs e)
{
Look();
}
public void Look()
{
DataSet newSet = UseDataadpater();
string str = "";
str = "<table border=1>";
for (int i = 0; i < newSet.Tables[0].Rows.Count; i++)
{
str = str + "<tr>";
for (int j = 0; j < newSet.Tables[0].Columns.Count; j++)
{
str = str + "<td>" + newSet.Tables[0].Rows[i].ItemArray[j] + "</td>";
}
str = str + "</tr>";
}
str = str + "</table>";
Label1.Text = str;
Response.Write(newSet.Tables[0].TableName);
}
}
运行后出现:Update 无法找到 TableMapping['Table'] 或 DataTable“Table”........
我在fill里已经指明此表叫Customers了 为什么在update的时候却找不到此表呢?
展开
 我来答
桂昀静0gp
2009-10-12 · 超过36用户采纳过TA的回答
知道小有建树答主
回答量:508
采纳率:0%
帮助的人:105万
展开全部
去这个blog看看吧
http://hi.baidu.com/fgmis
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式