代码如下:
- 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");