Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2005, 03:17 AM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to VishalPawar
Default ADO.Net connection object and InfoMessage event

Hi,
I am trying to use InfoMessage event associated with connection object.The command I am trying to execute is throwing error because it does not found the table with name a under my pubs database.
In that case the connection_InfoMessage event must be fired but in my case I am getting nothing under this event.
Why this event is not firing?
Please do correct me if I am taking it in wrong approach.

Regards,
Vishal Pawar


Code:
//**********************Sample code***************************

private void GetData()
{
SqlConnection connection=new SqlConnection();
connection.ConnectionString=ConfigurationSettings.AppSettings["ConStr"].ToString();
connection.InfoMessage+=new SqlInfoMessageEventHandler(connection_InfoMessage); 
connection.Open();
try{

    SqlCommand command=new SqlCommand("select * from a",connection);

    SqlDataReader dataReader=command.ExecuteReader();

    connection.Close();
}
catch(Exception)
{
}
}
public void connection_InfoMessage(object src,System.Data.SqlClient.SqlInfoMessageEventArgs e)
{
    foreach(SqlError err in e.Errors)
    {
        Response.Write("<br>Line number:"+err.LineNumber);
        Response.Write(" nbsp;Message:"+err.Message);
    }
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
remote connection object in asp.net nirmalbarsainyan ASP.NET 2.0 Basics 1 August 9th, 2007 06:27 PM
Connection to Oracle with ADO.NET In Webservices shahnawaz ADO.NET 1 October 10th, 2005 04:31 AM
Exclusive ADO Connection bsa SQL Server 2000 2 August 24th, 2004 12:10 AM
ADO Connection String jmss66 Classic ASP Basics 3 February 3rd, 2004 12:10 PM
Global ADO Connection object DaveParry123 ADO.NET 0 October 7th, 2003 03:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.