A server error has occurred: ERROR: Unexpected ERROR from SHRWTSK5 detected by TERMINATE WORK TASK in "ERREB"(0): ERROR: Generic critical error.; fn =yhelasg; context =sase9lib.dll.
using (OleDbConnection conn = new OleDbConnection(GlobalConfig.SASConn()))
{
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "libname survlib '" + pSASSurveyFolder3 + "'";
cmd.ExecuteNonQuery();
cmd.CommandType = CommandType.TableDirect;
cmd.CommandText = "vstatps";
//other option is to use the cmd.ExecuteReader();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(sasDs);
}
I searched internal information here and found a documented problem that has been addressed in a SAS/SHARE hotfix:
https://support.sas.com/kb/62/346.html
I don't know if you have any control/influence on this SAS/SHARE server to request that all hotfixes get applied. If not, I'm not sure how to address. You might try using the SAS/SHARE ODBC driver instead, which might follow a different code path.
For a test, try the project I've shared here to connect a .NET application to a SAS Workspace and data. There are some tricks, including the ObjectKeeper mechanism to reference the SAS connection during your session.
Thanks Chris..Will check it out.
Chris, I checked out your project and your connection string looks different than mine. Mine looks like this.
return @"Provider = sas.shareprovider.1; data source = xxxx; location = xxxx; SAS Server Access Password =xxxx";
It looks like you are trying to connect to a SAS/SHARE server. Is that correct? You aren't connecting to a SAS Workspace via SAS Integration Technologies?
Basic example for SAS/SHARE (and I mean really basic) is in this doc.
We also have an ODBC driver for SAS/SHARE, might be worth testing if that's your case.
Yes, you are correct. The Basic example for SAS/SHARE you linked is exactly what my connection string looks like. My issue is what to do next. Using the connection, I connect to the libraries like this.
cmd.Connection = conn;
cmd.CommandText = "libname survlib '" + pSASSurveyFolder + "'";
cmd.ExecuteNonQuery();
At this point, no errors. It's when I try to retrieve data from the datasets using a sql statement that I get an error. It's here that I need some guidance. Thanks for the help!!!
I think your CommandText should be an SQL command. Ex:
select * from SURVLIB.VSTATPS
Ok. I just tried that and now it says that "SURVLIB" is not assigned. Don't we define the library first and then execute sql?
Usually with SAS/SHARE the library is already defined. That's the point of SAS/SHARE -- to enable other applications to connect to curated data sources that are maintained in a SAS environment, served up by a SAS/SHARE server. It's not a place to run SAS code (like a LIBNAME statement) -- that's a SAS Workspace.
Thanks Chris. Will try it...
Everything works fine until I try to execute the reader and I get this:
Error A server error has occurred: ERROR: Unexpected ERROR from SHRWTSK8 detected by TERMINATE WORK TASK in "ERREB"(0): ERROR:
Generic critical error.; fn =yhelasg; context =sase9lib.dll.
I searched internal information here and found a documented problem that has been addressed in a SAS/SHARE hotfix:
https://support.sas.com/kb/62/346.html
I don't know if you have any control/influence on this SAS/SHARE server to request that all hotfixes get applied. If not, I'm not sure how to address. You might try using the SAS/SHARE ODBC driver instead, which might follow a different code path.
Thanks Chris..Will read the article and see what can be done.
You could try something like this.
cmd.Connection = conn; cmd.CommandText = "libname survlib '" + pSASSurveyFolder + "';"; cmd.ExecuteNonQuery(); cmd.CommandType = CommandType.TableDirect; cmd.CommandText = "survlib.vstatps"; OleDbDataReader myReader = cmd.ExecuteReader();
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.