当前位置: 代码迷 >> ASP.NET >> DataSet Update有关问题,从一个数据库读数据利用DataSet插入到另一个数据库表中
  详细解决方案

DataSet Update有关问题,从一个数据库读数据利用DataSet插入到另一个数据库表中

热度:9149   发布时间:2013-02-25 00:00:00.0
DataSet Update问题,从一个数据库读数据利用DataSet插入到另一个数据库表中
代码如下:
C# code
        protected void Button1_Click(object sender, EventArgs e)        {            DataSet myds = new DataSet();            string sel_com = " select recv_treasury_code,No,budget_level_code,subject_code,amount,state,work_date from tax_return where work_date>'20120601' and state=9 ";            string constrint_o = System.Configuration.ConfigurationManager.AppSettings["hncsk_oracle"];            OracleConnection conn_o = new OracleConnection(constrint_o);            string constring_sql = System.Configuration.ConfigurationManager.AppSettings["hncsk_sql"];            SqlConnection conn_s = new SqlConnection(constring_sql);            try            {                conn_o.Open();                OracleDataAdapter myda_o = new OracleDataAdapter();                myda_o.SelectCommand = new OracleCommand(sel_com, conn_o);                myda_o.Fill(myds);                GridView1.DataSource = myds.Tables[0].DefaultView;                GridView1.DataBind();                try {                    conn_s.Open();                    SqlDataAdapter sqlDa = new SqlDataAdapter();                                        int rowAff = sqlDa.Update(myds, "tax_return_his");                    Literal1.Text = "<script>alert('" + rowAff + "行受影响 !')</script>";                }                catch                {                    Literal1.Text = "<script>alert('写入数据库时出错 !')</script>";                }            }            catch            {                Literal1.Text = "<script>alert('打开数据库时出错 !')</script>";            }            finally            {                conn_o.Close();            }        }

int rowAff = sqlDa.Update(myds, "tax_return_his");出错!
从oracle读取数据到DataSet已成功,插入时报错,提示找不到tax_return_his表!

------解决方案--------------------------------------------------------
myda_o.Fill(myds,"tax_return_his");
  相关解决方案