It’s a bit like playing the guitar: easy when you know how! It took me a little while today, though, as the SAS samples weren’t very clear. What was missing was primarily how to fully specify the SAS library _and_ dataset programmatically.
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = "Provider=sas.IOMProvider; Data Source=_LOCAL_";
Console.WriteLine("SAS Server Version: " + cn.ServerVersion);
// Create an OleDbCommand object and tell it
// 1) to assign the library
OleDbCommand sascmd = cn.CreateCommand();
sascmd.CommandType = CommandType.Text;
sascmd.CommandText = @"libname cslib 'D:\SAS_RDB\SAS_DATA\v8\1996\'";
// 2) to open the specified table.
sascmd.CommandType = CommandType.TableDirect;
sascmd.CommandText = "cslib.aregn96";
// Execute the command and get an OleDbDataReader object.
OleDbDataReader reader = scmd.ExecuteReader();
As you see the trick is to assign the LIBRARY reference programatically.