The following
C# code shows how to display information about the SAS data set type,
label, and encoding for the data set named Shoes in the SASUSER library.
This code
applies to the local provider.
// obConnection is an open Connection object.
Recordset rs = new Recordset();
try {
rs.ActiveConnection = obConnection;
rs.Open("shoes", Type.Missing, CursorTypeEnum.adOpenForwardOnly,
LockTypeEnum.adLockReadOnly,
(int)CommandTypeEnum.adCmdTableDirect);
// Recordset Properties for the input table
Console.WriteLine("SAS Data Set Type property: " +
rs.Properties["SAS Data Set Type"].Value);
Console.WriteLine("SAS Data Set Label property: " +
rs.Properties["SAS Data Set Label"].Value);
Console.WriteLine("SAS Data Set Encoding property: " +
rs.Properties["SAS Data Set Encoding"].Value);
Console.WriteLine("SAS Data Set Windows Code Page property: " +
rs.Properties["SAS Data Set Windows Code Page"].Value);
rs.Close();
} catch (Exception e) {
// exception handling
}
The following
C# code produces similar results to the previous example, but accesses
the Schema Rowset Tables. The code applies to the local provider and
SAS/SHARE provider.
// obConnection is an open Connection object.
Recordset rs = new Recordset();
try {
rs.ActiveConnection = obConnection;
object[] restrictions = new object[] { null, null, "shoes" };
rs = obConnection.OpenSchema( SchemaEnum.adSchemaTables,
restrictions, Type.Missing);
// Fields of the Tables schema rowset for the input table
Console.WriteLine("SAS_DATASET_TYPE field:" +
rs.Fields["SAS_DATASET_TYPE"].Value);
Console.WriteLine("SAS_DATASET_LABEL field:" +
rs.Fields["SAS_DATASET_LABEL"].Value);
Console.WriteLine("SAS_DATASET_ENCODING field:" +
rs.Fields["SAS_DATASET_ENCODING"].Value);
Console.WriteLine("SAS_DATASET_WINDOWS_CODEPAGE field: " +
rs.Fields["SAS_DATASET_WINDOWS_CODEPAGE"].Value);
rs.Close();
} catch (Exception e) {
// exception handling
}