简体   繁体   中英

not append from to DBF file with c#

I can't append txt delimited with tab to dbffile. vfpoledb is installed, this is my code:

string path = "C:\\OTA\\sdf";
string strCon = String.Format(@"Provider=VFPOLEDB;Data Source={0};", path);

using (OleDbConnection cnx = new OleDbConnection(strCon))
{
    OleDbCommand cmd = cnx.CreateCommand();
    cnx.Open();
    cmd.CommandText = 
       @"EXECSCRIPT('USE CCD' + chr(13) + chr(10) + 'APPEND FROM ""C:\OTA\sdf\DETATXT.TXT"" DELIMITED WITH TAB')";
    cmd.ExecuteNonQuery(); // here is the error
    return "OK";
}

error: Unhandled exception of type 'System.Data.OleDb.OleDbException' in System.Data.dll Additional Information: Feature is not available.

ExecScript DOES work with VFP OleDb and I have used in the past, based on Append type CSV. It MIGHT be an issue with your formatting of the command and the extra quotes. For grins, try formatting it this way.

cmd.CommandText = string.Format(
@"EXECSCRIPT('
USE CCD
APPEND FROM [{0}] DELIMITED WITH TAB'", @"C:\OTA\sdf\DETATXT.TXT" );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM