问题:{"Update 无法找到 TableMapping['ds'] 或 DataTable“ds”。"} System.Exception {System.InvalidOperationExce
问题:{"Update 无法找到 TableMapping['ds'] 或 DataTable“ds”。"} System.Exception {System.InvalidOperationException}error code:
int count = adapter.Update(ds, "ds"); //----------cs.file-------------
1. protected void btnOK_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
User_Info entity = new User_Info();
entity.GetModel("UI_ID =" +Session["ManageInfo"].ToString()); if (entity.UI_PassWord == this.txtoldPwd.Text.Trim())
{
entity.UI_PassWord = this.txtNewPwd.Text.Trim();
// Response.Write(entity.UI_PassWord);
ResultInfo result = entity.update();
//------------------
2. public ResultInfo update()
{
try
{
bool isBool = DbHelperSQL.Update(ds, sqlInit);
if (isBool == true)
{
return new ResultInfo(0);
}
else
{
return new ResultInfo(-1); }
}
catch (Exception ex)
{
return new ResultInfo(-1, ex.Message);
}
}
//-----------------------------------
3. public static bool Update(DataSet ds, string sql)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
上面的SQL可以得到 select * from user_Info where 1!=1
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
try
{
int count = adapter.Update(ds, "ds");//??????????????????如查Count =1 is true ,而现在 COUNT 为0
if (count > 0)
{
return true;
}
else
{
return false;
}
}
catch (System.Data.SqlClient.SqlException ex)
{
throw new Exception(ex.Message);
}
}
}
int count = adapter.Update(ds, "ds"); //----------cs.file-------------
1. protected void btnOK_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
User_Info entity = new User_Info();
entity.GetModel("UI_ID =" +Session["ManageInfo"].ToString()); if (entity.UI_PassWord == this.txtoldPwd.Text.Trim())
{
entity.UI_PassWord = this.txtNewPwd.Text.Trim();
// Response.Write(entity.UI_PassWord);
ResultInfo result = entity.update();
//------------------
2. public ResultInfo update()
{
try
{
bool isBool = DbHelperSQL.Update(ds, sqlInit);
if (isBool == true)
{
return new ResultInfo(0);
}
else
{
return new ResultInfo(-1); }
}
catch (Exception ex)
{
return new ResultInfo(-1, ex.Message);
}
}
//-----------------------------------
3. public static bool Update(DataSet ds, string sql)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
上面的SQL可以得到 select * from user_Info where 1!=1
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
try
{
int count = adapter.Update(ds, "ds");//??????????????????如查Count =1 is true ,而现在 COUNT 为0
if (count > 0)
{
return true;
}
else
{
return false;
}
}
catch (System.Data.SqlClient.SqlException ex)
{
throw new Exception(ex.Message);
}
}
}
int count = adapter.Update(ds.table[0]);