private void btnUploadToDatabase_Click(object sender, EventArgs e) { try { InsertData insertdata = new InsertData(); string errorInfo = insertdata.InsertDataIntoSQLServerUsingSQLBulkCopy(csv, TableName); if (errorInfo == "") { MessageBox.Show("上传到数据库成功", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show($"上传到数据库失败,{errorInfo}", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("上传到数据库失败,原因:" + ex.Message, "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmMain frmmain = (frmMain)this.Owner; string sql = "select LIST,MACADDRESS,DESCRIPTION,VALIDFROM,VALIDTHRU from DhcpFilterStatus where STATUS !='deleting'"; frmmain.dt = SqlHelpers.ExecuteDataTable(CommandType.Text, sql); frmmain.dgvData.DataSource = frmmain.dt; dgvFileData.DataSource = null; }