strangelights.com

Main F# Site

Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Search
List all versions List all versions
F Sharp Ole Db
.
Summary
F# and OleDb sample by Stephen Bolding, writing in the F# mailing list
        open System
        open System.Data
        open System.Data.OleDb
        open System.Console


        let connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\usr\\my_db.mdb;UserId=admin;Password=;"
        let dbconn = new OleDbConnection(connstr);; 
        do dbconn.Open() 
        let sql_command= new OleDbCommand("select perf from perfs where id = 1",dbconn)
        let sql_stream : Collections.Generic.IEnumerable<System.Data.Common.DbDataRecord>  =
                sql_command.ExecuteReader(CommandBehavior.CloseConnection) |>                                         IEnumerable.untyped_to_typed ;;
        let sql_output = sql_stream  |> IEnumerable.map (fun x -> x.GetDouble 0 )
                |> IEnumerable.to_array;;
        print_any sql_output;

Useful, as OleDb can connect to most kinds of databases.

Welcome to F Sharp Wiki, view the HomePage

This site supports the new NoFollow anti-spam initiative.

Recent Topics

Copyright 2005, Robert Pickering (Others where credited) | Terms of Use