How to remove records from CSV in C#? -
i'm trying remove records csv formatted text file. here code reading , inserting records:
oledbconnection con = new oledbconnection(); con.connectionstring = constr; con.open(); oledbcommand com = new oledbcommand(); com.connection = con; com.commandtext = "select * shop.txt id '" + textboxsearch.text + "%'"; oledbdataadapter da = new oledbdataadapter(com); dataset ds = new dataset(); da.fill(ds); com.executenonquery(); datagridview1.datasource = ds.tables[0].defaultview; con.close();
but dont work remove. remove query this: delete * shop.txt id <something>
note: when calling executenonequery
following exception occurred
oledbexception: deleting data in liked list not supported in isam.
deleting rows textfile not easy - ole adapter doesn't support it. options:
- select data want keep
datatable
, export csv file. - parse csv file, filter unwanted lines , write other lines csv file. might bit faster using ole load data memory , dump them out.
Comments
Post a Comment