BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9
My application allows users to change data in a grid and update the values within my sas data tables. That part works correctly. What I need to know is how to capture an error that sas throws and return it to my windows application and display it?
9 REPLIES 9
ChrisHemedinger
Community Manager
What's the context here? Is this a custom task within EG or just a Windows app that you created with .NET?

If you are using the IOM LanguageService to issue a query (PROC SQL UPDATE), you would need to use the FlushLog or FlushLogLines call to get the SAS log, which would contain any errors/warning along with the rest of the SAS log.

If this is a custom task, there are are some wrapper classes that I can point you to. If that's the case, then we need to know whether this is EG 4.1 or 4.2.

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
jerry898969
Pyrite | Level 9
Chris,
Thank you so much for your response.

It is a windows forms "C#" app. I sending regular sql statements to SAS/Share server using OleDB. This is a sample of the updates I pass in.

"update system.user set UserNumber = '001' where ID = 1 and PRJID = 11"

Lets assume that UserNumber has a unique key constraint and that someone else already has '001'. I need to get the sas error message because it tells me what table and what constraint was violated.

Any help pointing me in the right direction would be appreciated.

Thank You
ChrisHemedinger
Community Manager
Jerry,

I see. You are manipulating the data via the provider, not with IOM and Language Service.

You probably already know about these resources:

The SAS OLE DB "cookbook":
http://support.sas.com/documentation/tools/oledb/index.htm

Handling Error Objects:
http://support.sas.com/documentation/tools/oledb/app_error_objects.htm

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
jerry898969
Pyrite | Level 9
Chris,
Would it be more advantages to use IOM? I'm not too familier with it but if it can speed up my app talking to SAS/Share server then I can look into it.

Have you used it? What are you thoughts on it, if you don't mind?

Thanks again
ChrisHemedinger
Community Manager
First, IOM requires that you have SAS Integration Technologies on your server. So if you have that, it's a good start.

IOM offers the LanguageService interface to allow you to run SAS programs and gather the logs and results. You can also access data like you do now, but using the SAS IOM OLE DB provider.

If all you need to do is treat your SAS/Share server like a database, then your current approach is probably fine. Are you using ADO or ADO.NET? And do you have a more complete C# example for how you are working with this? That would help our experts here to give advice.

This isn't exactly the correct forum for this, but I know there probably isn't another that is a better fit.

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
jerry898969
Pyrite | Level 9
Chris,
That is pretty much all I need to is treat sas/share like a database.

Here is an example of how i'm using it:

using System.Data.OleDb;

string conn = "Provider=sas.ShareProvider.1;Data Source=Share1;Location=server1;Mode=Read|Share Deny None";

OleDbConnection connSAS = new OleDbConnection(conn);
connSAS.Open();

OleDbCommand sasCommand = connSAS.CreateCommand();
sasCommand.CommandType = CommandType.Text;

sasCommand.CommandText = "update system.temp set fname='bob' where id = 10";

try
{
sasCommand.ExecuteNonQuery();
}
catch (System.Exception exc)
{
MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

Is it possible from what i'm doing to get the exact error back from SAS or do I have to take a different approach?

Thanks for your help that is a big problem for me and your help is appreciated.

Jerry
jerry898969
Pyrite | Level 9
Can anyone please just point me in the right direction?
I just want to know how to pull the sas error message to my C# application using oledb to run my sql.

Thank You
Ken_Work
Calcite | Level 5
Hello,

I am having the same problem and wonder if it is possible to create/modify SAS dataset this way.

If you already figure out a way, please post your solution.

Thank you,
Ken

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 971 views
  • 0 likes
  • 3 in conversation