更新语句为:
UPDATE financetable SET '"+ dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText +"' = '" + dataGridView1.CurrentCell.Value + "' WHERE (编号 = '" + dataGridView1.SelectedRows[0].Cells[0].Value + "')
运行时,会报错,提示dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText所在的数据库列名附近有错。例如,我更改日期列的某一日期,会提示'日期'附近有语法错误;若把dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText直接改为日期(表的列名)则不会报错。是哪里出问题了呢?
UPDATE financetable SET '"+ dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText +"' = '" + dataGridView1.CurrentCell.Value + "' WHERE (编号 = '" + dataGridView1.SelectedRows[0].Cells[0].Value + "')
运行时,会报错,提示dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText所在的数据库列名附近有错。例如,我更改日期列的某一日期,会提示'日期'附近有语法错误;若把dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText直接改为日期(表的列名)则不会报错。是哪里出问题了呢?
UPDATE financetable SET "+ dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText +" = '" + dataGridView1.CurrentCell.Value + "' WHERE (编号 = '" + dataGridView1.SelectedRows[0].Cells[0].Value + "'
放入查询分析器看下! set后面是字段名你加引号干嘛