<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Read/Write SAS dataset using c# .net and SAS universal viewer &amp;amp; OLEDB provider in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360479#M274658</link>
    <description>&lt;P&gt;We have the following requirement where user is having only OLE DB and SAS universal viewer. Could you please confirm, shall we Read/Write SAS dataset using C# with local SAS universal viewer and OLEDB connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Requirement: &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Read the SAS file table ((.sas7bdat) content and push it to any of the database (SQL or Oracle) using C# .Net&lt;/LI&gt;&lt;LI&gt;Generate the SAS dataset file (.sas7bdat) from database content (SQL or Oracle) using C# .Net&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To achieve this, we are doing the following have to do the following steps in visual studio with following references. &amp;nbsp;However we are getting the issue while creating a local workspace which highlighted in yellow colour.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Step 1 – Add references to the &lt;STRONG&gt;SAS IOM and the SASWorkspaceManager&lt;/STRONG&gt; Type Library to the project.&lt;/LI&gt;&lt;LI&gt;Step 2 – Obtain a SAS workspace manager object from the IOM.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WorkspaceManager sasWM = new SASWorkspaceManager.WorkspaceManager();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sasWS = (SAS.Workspace)sasWM.Workspaces.CreateWorkspaceByServer("LocalWS", Visibility.VisibilityProcess, null, "", "", out xmlInfo);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Step 3 – Create an OleDb connection object using the IOM provider.&lt;/LI&gt;&lt;LI&gt;Step 4 – Create and execute an ADO.NET command to set the location of the SAS datasets.&lt;/LI&gt;&lt;LI&gt;Step 5 – Create an ADO.NET data adapter object to retrieve the data from SAS datasets or create and execute an ADO.NET command to modify data in a SAS dataset.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Code for above steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;SAS.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Workspace&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sasWS;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;string&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; xmlInfo; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;WorkspaceManager&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sasWM = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; SASWorkspaceManager.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;WorkspaceManager&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;sasWS = (SAS.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Workspace&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;)sasWM.Workspaces.CreateWorkspaceByServer(&lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"LocalWS"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Visibility&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.VisibilityProcess, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;null&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;""&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;""&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; xmlInfo); &lt;/FONT&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;//Here i am getting the error&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbConnection&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; conn = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbConnection&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;conn.ConnectionString = &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"Provider=sas.IOMProvider; SAS Workspace ID="&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; + sasWS.UniqueIdentifier;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;// Set SAS dataset library path (libname)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbCommand&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; cmd = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbCommand&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;cmd.Connection = conn;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;cmd.CommandType = &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;CommandType&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.Text;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;cmd.CommandText = &lt;/FONT&gt;&lt;FONT color="#800000" face="Consolas" size="2"&gt;@"libname MyLib 'c:\temp\IOM'"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;conn.Open();&lt;/P&gt;&lt;P&gt;cmd.ExecuteNonQuery();&lt;/P&gt;&lt;P&gt;conn.Close();&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;// Retrieve SAS data into a DataSet&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;string&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sql = &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"select * from MyLib.DV"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbDataAdapter&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; da = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbDataAdapter&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(sql, conn);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;System.Data.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DataSet&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; ds = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; System.Data.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DataSet&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"SAS"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;da.Fill(ds);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;//WriteDataSet(ds.Tables[0]);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Error Details:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SASReader.exe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additional information: &amp;lt;connectionAttempts&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;connectionAttempt&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sasserver&amp;gt;&amp;lt;/sasserver&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sasmachinednsname&amp;gt;&amp;lt;/sasmachinednsname&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sasport&amp;gt;0&amp;lt;/sasport&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saslogin&amp;gt;&amp;lt;/saslogin&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;status&amp;gt;0x80040154&amp;lt;/status&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;description&amp;gt;Class not registered&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/description&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/connectionAttempt&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/connectionAttempts&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2017 16:11:47 GMT</pubDate>
    <dc:creator>mmsiva</dc:creator>
    <dc:date>2017-05-22T16:11:47Z</dc:date>
    <item>
      <title>Read/Write SAS dataset using c# .net and SAS universal viewer &amp; OLEDB provider</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360479#M274658</link>
      <description>&lt;P&gt;We have the following requirement where user is having only OLE DB and SAS universal viewer. Could you please confirm, shall we Read/Write SAS dataset using C# with local SAS universal viewer and OLEDB connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Requirement: &lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Read the SAS file table ((.sas7bdat) content and push it to any of the database (SQL or Oracle) using C# .Net&lt;/LI&gt;&lt;LI&gt;Generate the SAS dataset file (.sas7bdat) from database content (SQL or Oracle) using C# .Net&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To achieve this, we are doing the following have to do the following steps in visual studio with following references. &amp;nbsp;However we are getting the issue while creating a local workspace which highlighted in yellow colour.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Step 1 – Add references to the &lt;STRONG&gt;SAS IOM and the SASWorkspaceManager&lt;/STRONG&gt; Type Library to the project.&lt;/LI&gt;&lt;LI&gt;Step 2 – Obtain a SAS workspace manager object from the IOM.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WorkspaceManager sasWM = new SASWorkspaceManager.WorkspaceManager();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sasWS = (SAS.Workspace)sasWM.Workspaces.CreateWorkspaceByServer("LocalWS", Visibility.VisibilityProcess, null, "", "", out xmlInfo);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Step 3 – Create an OleDb connection object using the IOM provider.&lt;/LI&gt;&lt;LI&gt;Step 4 – Create and execute an ADO.NET command to set the location of the SAS datasets.&lt;/LI&gt;&lt;LI&gt;Step 5 – Create an ADO.NET data adapter object to retrieve the data from SAS datasets or create and execute an ADO.NET command to modify data in a SAS dataset.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Code for above steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;SAS.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Workspace&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sasWS;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;string&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; xmlInfo; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;WorkspaceManager&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sasWM = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; SASWorkspaceManager.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;WorkspaceManager&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;sasWS = (SAS.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Workspace&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;)sasWM.Workspaces.CreateWorkspaceByServer(&lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"LocalWS"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;Visibility&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.VisibilityProcess, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;null&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;""&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;""&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; xmlInfo); &lt;/FONT&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;//Here i am getting the error&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbConnection&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; conn = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbConnection&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;conn.ConnectionString = &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"Provider=sas.IOMProvider; SAS Workspace ID="&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; + sasWS.UniqueIdentifier;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;// Set SAS dataset library path (libname)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbCommand&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; cmd = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbCommand&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;cmd.Connection = conn;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;cmd.CommandType = &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;CommandType&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.Text;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;cmd.CommandText = &lt;/FONT&gt;&lt;FONT color="#800000" face="Consolas" size="2"&gt;@"libname MyLib 'c:\temp\IOM'"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;conn.Open();&lt;/P&gt;&lt;P&gt;cmd.ExecuteNonQuery();&lt;/P&gt;&lt;P&gt;conn.Close();&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;// Retrieve SAS data into a DataSet&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;string&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; sql = &lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"select * from MyLib.DV"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbDataAdapter&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; da = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt; &lt;FONT color="#2b91af" face="Consolas" size="2"&gt;OleDbDataAdapter&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(sql, conn);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;System.Data.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DataSet&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; ds = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; System.Data.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DataSet&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#a31515" face="Consolas" size="2"&gt;"SAS"&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;da.Fill(ds);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Consolas" size="2"&gt;//WriteDataSet(ds.Tables[0]);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Error Details:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SASReader.exe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additional information: &amp;lt;connectionAttempts&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;connectionAttempt&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sasserver&amp;gt;&amp;lt;/sasserver&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sasmachinednsname&amp;gt;&amp;lt;/sasmachinednsname&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sasport&amp;gt;0&amp;lt;/sasport&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;saslogin&amp;gt;&amp;lt;/saslogin&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;status&amp;gt;0x80040154&amp;lt;/status&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;description&amp;gt;Class not registered&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/description&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/connectionAttempt&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/connectionAttempts&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 16:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360479#M274658</guid>
      <dc:creator>mmsiva</dc:creator>
      <dc:date>2017-05-22T16:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Read/Write SAS dataset using c# .net and SAS universal viewer &amp; OLEDB provider</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360491#M274659</link>
      <description>Hi, for a question like this, especially one with an error message, your best resource is SAS Tech Support.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Mon, 22 May 2017 17:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360491#M274659</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-05-22T17:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Read/Write SAS dataset using c# .net and SAS universal viewer &amp; OLEDB provider</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360592#M274660</link>
      <description>&lt;P&gt;As I understand it, this isn't going to work. As the name suggests the SAS Universal Viewer is just for viewing existing SAS datasets. You can't use it to translate from or to other data types / sources:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/onlinedoc/univiewer/" target="_blank"&gt;http://support.sas.com/documentation/onlinedoc/univiewer/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to have a working version of SAS installed to do what you want - to read a SAS dataset and load it into a DBMS table or vice versa. The only other option I can think of would be a third-party tool that can translate SAS datasets&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 00:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360592#M274660</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-05-23T00:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Read/Write SAS dataset using c# .net and SAS universal viewer &amp; OLEDB provider</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360595#M274661</link>
      <description>&lt;P&gt;To create a local Workspace, you need a local version of SAS installed. &amp;nbsp;And method is something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  &lt;SPAN class="pl-en"&gt;SAS.Workspace&lt;/SPAN&gt;&lt;SPAN&gt; _workspace = null;&lt;/SPAN&gt;&lt;BR /&gt;  // Connect using COM protocol, locally installed SAS only
  SASObjectManager.IObjectFactory2 obObjectFactory = new SASObjectManager.ObjectFactoryMulti2();
  SASObjectManager.ServerDef obServer = new SASObjectManager.ServerDef();
  obServer.MachineDNSName = "localhost";
  obServer.Protocol = SASObjectManager.Protocols.ProtocolCom;
  obServer.Port = 0;
  _workspace = (SAS.Workspace)obObjectFactory.CreateObjectByServer(Name, true, obServer, null, null);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 00:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Write-SAS-dataset-using-c-net-and-SAS-universal-viewer-amp/m-p/360595#M274661</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-05-23T00:54:05Z</dc:date>
    </item>
  </channel>
</rss>

