I have the following record type "tbl" and it will contain lists or seq. How can i save/update this "tbl" into an existing access db table using f sharp with the field names as specified below.
type Tbl= { P:string;
In:System.DateTime;
Ex:System.DateTime;
B:string;
CC:string;
GG:double;
PR:double;
DE:double;
PRE:double;
DEU:double;
PRPL_DEDUC:double;
GUR:double;
GC:double;
PRP:double;
PDA:double;
PRO:double}
let conn = new OleDbConnection( @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=T:\Test.accdb;
Persist Security Info=False;" )
conn.Open()
let sql="INSERT INTO Test SELECT * FROM " Tbl
let DAdapter = new OleDbDataAdapter(sql,conn)
DAdapter.Update
There's a couple of things that come to mind here.
Firstly, I think you're tripping up on the interpretation of the record type - it isn't a recordset - so you can't just pump into an oledbdataadapter.
There's also not much support for Access in the F# type providers - I'm losing touch with how many are there but as an example SqlProvider lets you read from Access but not perform CRUD actions.
So, at least as far as I know, the old fashioned oledb approach you've got above is actually the right path here.
The code below uses SqlProvider to retrieve the contents of an access db with 3 columns, the saveARow function won't work and then it goes on to do it the oledb way...