Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PRINT statements in SQL and SQLDataReader

49 views
Skip to first unread message

Andrew...@cenveo.com

unread,
Jan 15, 2010, 8:20:33 PM1/15/10
to
I've run into an issue when trying to execute a Sybase stored
procedure that contains PRINT statements. I've tried putting the
InfoMessage handler on the connection, but the problem is, I don't
want to halt execution of the Reader. The read fails each time, with
the exception message being whatever the PRINT statement in the SQL
was.

Here's a code snipet. Can anyone tell me how to get past the
exception? I really need to ignore the PRINT statements and move on.

AseConnection cn = new AseConnection
(ConfigurationManager.ConnectionStrings
["ASEConnection"].ConnectionString); //Set
connection
cn.InfoMessage += new AseInfoMessageEventHandler
(cn_InfoMessage);
AseCommand cmd = new AseCommand("sspGetLtLabelShapes",
cn); //to workflow_data
AseDataReader dr;
ArrayList al = new ArrayList
(); //Array List for the Shapes


cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@inSetID",
SETID); // Loading SetID


try

{ //
Attempt to hit the DB for Shapes
cn.Open();
dr = cmd.ExecuteReader(CommandBehavior.Default);
while (dr.Read())
{
Label lb = new Label
(); // Create new label for arrary

lb.Id = dr["shape_id"].ToString
(); // Set Label ID
lb.Name = dr["shape_descr"].ToString
(); // Set Label Name

al.Add
(lb); // Add it to the
list
}
Labels = (Label[])al.ToArray(typeof
(Label)); // Convert the Array list to an array for
return
}
catch (Exception ex)

{ //
In the event of failure
Labels = new Label
[1]; // return the error in
the shape name
Labels[0] = new Label
(); // and a zero in the ID
Labels[0].Name = ex.Message;
Labels[0].Id = "0";
}
finally
{
cn.Close
(); // Clean it up
cn.Dispose();
cmd.Dispose();
al.Clear();
}

Andrew...@cenveo.com

unread,
Jan 15, 2010, 8:26:05 PM1/15/10
to
I meant to say ASEDataReader - my apologies.

Michael Garza

unread,
Jan 16, 2010, 3:19:40 PM1/16/10
to
I just ran a test with the latest driver and print statements inside my
stored procedures do not cause an exception to occur. What version of the
ADO.NET driver are you using?

<Andrew...@cenveo.com> wrote in message
news:413b61f3-ae00-416d...@q41g2000vba.googlegroups.com...

0 new messages