oledbeexception:功能未实现



有人知道发生了什么事吗?如果它删除了所有记录,但仍然返回一个异常

    OleDbConnection dbConn = new OleDbConnection(@"Provider=vfpoledb;Data Source=C:foxpro");
    try
    {
        dbConn.Open();
        using (OleDbCommand command = dbConn.CreateCommand())
        {
            command.CommandText = "execscript[('USE table in 0' + chr(13) + chr(10) + 'DELETE ALL')]";
            command.ExecuteNonQuery();       
        }            
    }
    catch (Exception ex)
    {
        Response.Write(ex.ToString());
    }
    finally
    {
        dbConn.Close();
    }

例外是:

System.Data.OleDb.OleDbException (0x80004005): Function is not implemented. at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at 
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at 
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at backbuttonclicked.Page_Load(Object sender,
EventArgs e) in e:MyProjectsprogramsFujiDocumentsPrintingbackbuttonclicked.aspx.cs:line 31

您可以尝试以下操作:

command.CommandText = "DELETE FROM tablename1";
command.ExecuteNonQuery();       

这也将删除文件中的所有记录。tablename1文件"。dbf'应该放在'C:foxpro'文件夹。否则,在SQL命令文本中使用完整的文件名

我已经成功地用下面的代码做了这种事情:

 string connectionString = @"Provider=VFPOLEDB.1;Data Source=c:foxpro"; 
    using (OleDbConnection connection = new OleDbConnection(connectionString)) 
    { 
        using (OleDbCommand scriptCommand = connection.CreateCommand()) 
        { 
            connection.Open();
            string vfpScript = @"SET EXCLUSIVE ON
                                USE table
                                DELETE ALL
                                PACK"; 
            scriptCommand.CommandType = CommandType.StoredProcedure; 
            scriptCommand.CommandText = "ExecScript"; 
            scriptCommand.Parameters.Add("myScript", OleDbType.Char).Value = vfpScript; 
            scriptCommand.ExecuteNonQuery(); 
        } 
    } 

DELETE ALL将这些记录标记为已删除,但不会将它们从表中删除。如果这是您想要的,那么删除PACK命令,该命令将从dbf中删除标记为已删除的所有记录。

您在一个触发器中有一个try catch,这是未实现的功能。今天遇到了同样的问题。

相关内容

  • 没有找到相关文章

最新更新