OleDbException:未实现函数

时间:2013-04-29 17:00:35

标签: c# asp.net oledb foxpro oledbconnection

有谁知道发生了什么?它会删除所有记录,但仍会返回异常

    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:\MyProjects\programs\FujiDocumentsPrinting\backbuttonclicked.aspx.cs:line 31

3 个答案:

答案 0 :(得分:0)

您可以尝试以下操作:

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

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

答案 1 :(得分:0)

我使用以下代码做了这样的事情取得了成功:

 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中标记为已删除的所有记录。

答案 2 :(得分:0)

您在其中一个触发器中尝试捕获,这是未实现的功能。今天遇到同样的问题。