我对这种方法有疑问。所有参数都在那里,并且按顺序排列,但我仍然收到此错误:ORA-01008: not all variables bound
protected void LastUpdateDates(string Path, string Key, bool Update)
{
//load the update dates of the mta files
try
{
FileInfo file = new FileInfo(Path);
string query = string.Empty;
if (myOleDbConnection.State == ConnectionState.Closed) { myOleDbConnection.Open(); }
OleDbCommand myOleDbCommand = new OleDbCommand();
query = "UPDATE USER_LINK_MTA_LOGS SET DT_ATUALIZACAO=:PDT, DS_CAMINHO=:PFULLNAME WHERE ID_ARQUIVO=:PKEY";
myOleDbCommand.Connection = myOleDbConnection;
myOleDbCommand.CommandText = query;
myOleDbCommand.Parameters.AddWithValue(":PDT", file.LastWriteTime);
myOleDbCommand.Parameters.AddWithValue(":PFULLNAME", file.FullName);
myOleDbCommand.Parameters.AddWithValue(":PKEY", Key);
myOleDbCommand.ExecuteNonQuery();
myOleDbCommand.Dispose();
}
catch (Exception exxx)
{
ErrorHandler.TreatError("Could not obtain MTA configuration\r\n" + exxx);
}
}
现在我尝试了?占位符 Skeet 说:
myOleDbCommand.Parameters.Add(file.LastWriteTime.ToString(),OleDbType.DBTimeStamp);
myOleDbCommand.Parameters.Add(file.FullName,OleDbType.VarChar);
myOleDbCommand.Parameters.Add(Key,OleDbType.VarChar);
当我运行 ExecuteNonQuery 时,上面的方法出现以下错误。
参数 [0] '' não tem valor padrão。翻译:参数 [0] 没有标准值。
参数 [1] '' não tem valor padrão。
参数 [2] '' não tem valor padrão。
在下面也尝试过这种方式,并且在设置参数时出错。
myOleDbCommand.Parameters.Add(file.LastWriteTime);
myOleDbCommand.Parameters.Add(file.FullName);
myOleDbCommand.Parameters.Add(Key);
OleDbParameterCollection 必须注意 OleDbParameter não nulos,não aceita objetos DateTime。
翻译:OleDbParameterCollection 只接受 OleDbParameter 类型的非空对象。不接受 DateTime 类型的对象。