访问数据库 table 更新替换
Access db table update replace
我想通过替换列 'ColName' 中的字符串来更新访问数据库 table 'TableName',如下所示:
Dim Sql As String = "UPDATE [" & TableName & "] SET [" & ColName & "] = REPLACE([" & ColName & "], '" & OldPart & "', '" & NewPart & "')"
Dim Cmd As new OleDbCommand
Cmd.Connection = My data bsae connection string
Cmd.CommandType = CommandType.Text
Cmd.CommandText = Sql
Cmd.ExecuteNonQuery()
我收到以下错误:
Data type mismatch in criteria expression.
我的代码有什么问题?
您可能有一些空白字段,所以试试这个:
Dim Sql As String = "UPDATE [" & TableName & "] SET [" & ColName & "] = REPLACE([" & ColName & "], '" & OldPart & "', '" & NewPart & "') WHERE [" & ColName & "] Is Not Null"
我想通过替换列 'ColName' 中的字符串来更新访问数据库 table 'TableName',如下所示:
Dim Sql As String = "UPDATE [" & TableName & "] SET [" & ColName & "] = REPLACE([" & ColName & "], '" & OldPart & "', '" & NewPart & "')"
Dim Cmd As new OleDbCommand
Cmd.Connection = My data bsae connection string
Cmd.CommandType = CommandType.Text
Cmd.CommandText = Sql
Cmd.ExecuteNonQuery()
我收到以下错误:
Data type mismatch in criteria expression.
我的代码有什么问题?
您可能有一些空白字段,所以试试这个:
Dim Sql As String = "UPDATE [" & TableName & "] SET [" & ColName & "] = REPLACE([" & ColName & "], '" & OldPart & "', '" & NewPart & "') WHERE [" & ColName & "] Is Not Null"