我正在尝试为 oledb 数据适配器编写更新命令。我有各种各样的错误。我认为我的绊脚石是我无能为力的愚蠢的字段名称。也许有人可以看到我的错误?
数据库是访问该表有很多列,但我只想更新一个。[Transaction Seq] 列是 AutoNumber 要更新的列 [Code (IAO)] 是文本 - 255 长
错误:参数 [@Code (IAO)] 没有默认值。
我的代码:
oDAtblBound.SelectCommand = New OleDb.OleDbCommand(strSql, oCon)
Dim builder As OleDb.OleDbCommandBuilder = New OleDbCommandBuilder(oDAtblBound)
builder.QuotePrefix = "["
builder.QuoteSuffix = "]"
oDAtblBound.MissingSchemaAction = MissingSchemaAction.AddWithKey
oDAtblBound.Fill(oTables, "tblBound")
cmd = New OleDbCommand("UPDATE tblBound SET [Code (IAO)] = [@Code (IAO)] WHERE [Transaction Seq] = [@Transaction Seq]", oCon)
cmd.Parameters.Add("[Code (IAO)]", OleDbType.Char, 255, "[Code (IAO)]")
parameter = cmd.Parameters.Add("[Transaction Seq]", OleDbType.Char, 255, "[Transaction Seq]")
parameter.SourceVersion = DataRowVersion.Original
oDAtblBound.UpdateCommand = cmd