OracleDataAdapter.Update()写不进数据库也不报错。求帮助啊。。。。
public static void Adapter_updateDB(DataTable dt)
{
string sql_str = "insert into t_avgwindspeed(DATETIME,WINDMILLNUM,WINDSPEED,POWER)values(@DATETIME,@WINDMILLNUM,@WINDSPEED,@POWER)";
//string sql_str = "insert into t_avgwindspeed(DATETIME,WINDMILLNUM,WINDSPEED,POWER,TIMECELL)values(@DATETIME,@WINDMILLNUM,@WINDSPEED,@POWER,@TIMECELL)";
Connection = new OracleConnection(Conn_str);
OracleCommand com = new OracleCommand(sql_str,Connection);
com.Parameters.Add("@DATETIME", OracleDbType.Date, 32, "时间");
com.Parameters.Add("@WINDMILLNUM", OracleDbType.Varchar2, 32, "风机名");
com.Parameters.Add("@WINDSPEED", OracleDbType.Varchar2, 32, "风速");
com.Parameters.Add("@POWER", OracleDbType.Varchar2, 32, "功率");
//com.Parameters.Add("@TIMECELL", OracleDbType.Varchar2, 32, "时间间隔");
com.UpdatedRowSource = UpdateRowSource.None;
OracleDataAdapter da = new OracleDataAdapter();
da.InsertCommand = com;
Connection.Open();
da.Update(dt);
Connection.Close();
}
问题 我已找到。datarow rowstate的状态added是就可以。如果是excel读取的da.AcceptChangesDuringFill = false;
还有values(:DATETIME,:WINDMILLNUM,:WINDSPEED,:POWER,:TIMECELL)";Oracle不用@
com.Parameters.Add("WINDMI", OracleDbType.Varchar2, 32, "风机名");