private void button2_Click(object sender, EventArgs e) { OracleDALLib dal = new OracleDALLib("StrConn"); DataTable tab = dal.Query("SELECT * FROM dept"); //DataTable tab = dal.Query("SELECT COPRODUCTION.*,to_char(time,'yyyy-mm-dd hh24:mi:ss') AS TIMES FROM COPRODUCTION"); dataGridView1.DataSource = tab; //dataGridView1.Columns["TIMES"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss"; }
private void btnImport_Click(object sender, EventArgs e) { if (ImportData != null && ImportData.Rows.Count > 0) { string SqlInsert = ""; int EffectRows = 0; OracleDALLib DALLib = new OracleDALLib("StrConn"); foreach (DataRow row in ImportData.Rows) { SqlInsert = @"INSERT INTO AUSWDATEN VALUES ('" + row["THMID"] + "'," + row["LINIENNR"] + ",'" + row["LINIENNAME"] + "'," + row["STATIONNR"] + ",'" + row["STATIONNAME"] + "','" + row["NAME"] + "','" + row["WERT"] + "',to_date('" + row["TIME"] + "','yyyy-mm-dd hh24:mi:ss')) "; EffectRows+= DALLib.ExcuteIDU(SqlInsert); } MessageBox.Show("新增" + EffectRows + "行!"); } else MessageBox.Show("数据不能为空!"); }