Home  |  Linux  | Mysql  | PHP  | XML
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: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server
Re: SQL connect error -101188867
Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server
Help on compiling PHP for MIPS, Bus Error thrown
RE: [PHP-WIN] What about php 5.3 and printers or PHP_PRINTER.DLL ?


  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants