Home  |  Linux  | Mysql  | PHP  | XML
Deprecated: Function ereg() is deprecated in /rscs/rs/websites/lmpx.com/code/nav/common.inc on line 99
Deprecated: Function ereg() is deprecated in /rscs/rs/websites/lmpx.com/code/nav/common.inc on line 82
From:Andrew.alford@cenveo.com Date:Sat Jan 16 01:20:33 2010
Subject:PRINT statements in SQL and SQLDataReader
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();
}
Navigate in group sybase.public.connectivity.adonet at sever forums.sybase.com
Previous Next


Your recent visits
Re: How to use connection.GetSchema()?
Re: Are MO5.7 working on Windows Mobile6.5
Re: migration from pb10.5 to pb11.1 winform - webservice errors
Re: SybSQLException: RAISERROR There is no object with the specifiedowner/name combination
Re: Error in applying EBF to Sybase SDK 15



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants