You write data-access code in a library project in exactly the same way as you write it in an application project. Code is code wherever you write it.
You'll have to pass the connection string, or at least its properties, into the library from the application. You'll also need to pass in the SQL statements or stored procedure names. If you want your code to be as generic as possible then look at using the DbProviderFactory as the centrepiece.
As for using your library in an application, you already do that all the time. Every type you use from the .NET Framework is defined in a DLL. Once you've added a reference to that DLL to your project it's all the same.