Go check out the recently released WF State Machine Activity Pack CTP 1 and ADO.NET Activity Pack CTP 1 at http://wf.codeplex.com. As published on the site,

“The Microsoft WF State Machine Activity Pack CTP 1 is the first community technology preview (CTP) release of a state machine implementation based on Windows Workflow Foundation in .NET Framework 4 (WF 4). The implementation contains not only a state machine runtime but also a graphical state machine designer.”

“The Microsoft WF ADO.NET Activity Pack CTP 1 is the first community technology preview (CTP) release of ADO.NET activities implementation based on Windows Workflow Foundation in .NET Framework 4 (WF 4). The implementation contains a set of activities as well as designers based on ADO.NET Data Providers, which enable access to a database through SQL commands or stored procedures within a workflow.”

Both activity packs are open sourced so you can download the source code and see just how this was done. There are user guides describing the features as well as instructions on how to use them.