BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
muungo60
Calcite | Level 5

 

 

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);

}

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

View solution in original post

13 REPLIES 13
ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
muungo60
Calcite | Level 5

Thanks Chris..Will check it out.

muungo60
Calcite | Level 5

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";

ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
muungo60
Calcite | Level 5

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!!!

ChrisHemedinger
Community Manager

I think your CommandText should be an SQL command. Ex:

select * from SURVLIB.VSTATPS
Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
muungo60
Calcite | Level 5

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?

ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
muungo60
Calcite | Level 5

Thanks Chris. Will try it...

muungo60
Calcite | Level 5

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.

ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
muungo60
Calcite | Level 5

Thanks Chris..Will read the article and see what can be done.

ChrisHemedinger
Community Manager

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();
Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 1417 views
  • 0 likes
  • 2 in conversation