日期:2014-05-17  浏览次数:21602 次

表达式中 'REPLACE' 函数未定义。
本帖最后由 realdrizzt 于 2013-12-30 12:57:51 编辑
private void button6_Click(object sender, EventArgs e)
        {
            OleDbConnection mycon = null;
            try
            {
                string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\1.mdb;";
                mycon = new OleDbConnection(strcon);
                mycon.Open();

                string sql1 = "Update temp SET 单据编号 = REPLACE(单据编号, 'SAR00', '')";
                OleDbDataAdapter ad1 = new OleDbDataAdapter(sql1, strcon);
                DataTable dt = new DataTable();
                
                ad1.Fill(dt);
                textBox3.Text = "导入完成";
            }
            finally
            {
                mycon.Close();
            }
        }

想把单据编号这个字段中SAR00都删除,用的access数据库

------解决方案--------------------
UPDATE temp  SET 单据编号= MID(单据编号, 1, INSTR(单据编号, 'SAR00') - 1) + '' + MID(单据编号, INSTR(单据编号, 'SAR00') + LEN('SAR00'), LEN(单据编号) - INSTR(单据编号, 'SAR00') - LEN('SAR00') + 1) WHERE INSTR(单据编号, 'SAR00') > 0;
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/