odbc - C# DBF Error Opening -


i trying write program read dbf file , put datatable. don't have experience working foxpro database. below funcation opens dbf. pass filename function.

private datatable loadfile(string filename) {     system.data.odbc.odbcconnection conn = new system.data.odbc.odbcconnection();     conn.connectionstring = "driver={microsoft dbase driver (*.dbf)};deleted=1";         datatable dt = new datatable();     try     {         conn.open();         system.data.odbc.odbccommand comm = new system.data.odbc.odbccommand();         comm.commandtext = @"select * " + @filename;          comm.connection = conn;          dt.load(comm.executereader());     }     catch (exception ex)     {         messagebox.show(ex.tostring());     }     finally{         conn.close();     }     return dt;  } 

the variable filename is

"c:\\users\\psun\\desktop\\new folder\\plog.dbf" 

at run time error

    error [42000] [microsoft][odbc dbase driver] syntax error in clause.    @ system.data.odbc.odbcconnection.handleerror(odbchandle hrhandle, retcode retcode)    @ system.data.odbc.odbccommand.executereaderobject(commandbehavior behavior, string method, boolean needreader, object[] methodarguments, sql_api odbcapimethod)    @ system.data.odbc.odbccommand.executereaderobject(commandbehavior behavior, string method, boolean needreader)    @ system.data.odbc.odbccommand.executereader(commandbehavior behavior)    @ system.data.odbc.odbccommand.executereader()    @ upload.form1.loadexcel(string filename) in c:\users\psun\documents\visual studio 2012\projects\plogreader\plogreader\form1.cs:line 60 

first, if working foxpro tables, not use dbase driver.

get microsoft visual foxpro oledb provider

second, connections strings. not want connection string mention actual table.dbf, path database files located. then, queries simple as...

select * sometable

additionally, there plenty of other q&a associated vfp , oledb. if seach of user id plus tags, list of questions i've offered out here. there many running scripts, simple querying, using parameterized queries, etc.

here example search put in... user:74195[vfp][oledb]


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -