上次,我们已经做完了准备工作,下面就要把数据写入到数据库中了.
新增按钮代码
OleDbConnection conn = new OleDbConnection(GlobalData.DbConn_Str);//打开excel数据库
int tempid = GlobalData.Id + 1;
string tempDate = dateTimePicker_ShiJian.Value.Year.ToString() + "年";
tempDate += dateTimePicker_ShiJian.Value.Month.ToString() + "月";
tempDate += dateTimePicker_ShiJian.Value.Day.ToString() + "日";
GlobalData.SQL_Str = "insert into " + GlobalData.Excel_Sheet + " values (" + tempid + ",'" + comboBox_ChanPin.Text + "'," + int.Parse(textBox_ShuLiang.Text.Trim()) + "," + int.Parse(textBox_DanJia.Text.Trim()) + "," + int.Parse(textBox_XiaoJi.Text.Trim()) + ",'" + textBox_JingShouRen.Text + "',