vb.net - Cannot connect to dbf file -
i'm trying connect to foxpro table (.dbf) test vb.net form. recieve oledbexception message "cannot open file c:\emp\emptbl.dbf"
have tried both of following connection strings:
provider=vfpoledb.1;data source=c:\emp\emptbl.dbf
from msdn article here
provider=vfpoledb;data source=c:\emp\emptbl.dbf;collating sequence=machine;
the latter seems type use when connecting single table, same exception thrown regadless of used.
i can open , perform same query okay in visual foxpro 6.0. here's code:
dim tbl datatable = new datatable() using con = new oledbconnection(constring) cmd = new oledbcommand() {.connection = con, .commandtype = commandtype.text} dim ssql string = "select * from(emptbl)" cmd.commandtext = ssql dim adp oledbdataadapter = new oledbdataadapter(cmd) dim ds dataset = new dataset() con.open() adp.fill(ds) con.close() if (ds.tables.count > 0) tbl = ds.tables(0) end if end using return tbl
the oledb provider should connect path tables are... not actual file name. once connect path, can query .dbf file located in it
provider=vfpoledb.1;data source=c:\emp
select * emptbl ...
you can @ other connection string settings at
update per comment.
it appears getting closer. attempt without () parens. in vfp, within parens, interprets "look variable called emptbl", , value name of table query from. not need apply via oledb connection.
now, cant open file another. possible application has table open , file in exclusive use? , can not opened .net app too? grins, if open vfp, , simple create table in c:\emp folder , put single record in it, know no other program using new file. quit out of vfp , try query table. there should no locks, no other program expecting it, should never opened else , should go.
Comments
Post a Comment