Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 September 28th, 2006, 06:13 AM
Registered User
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default An existing connection was forcibly closed by the

Hi all,
For the past 2 days i am getting an exception like this.
I this i am using remoting concept.
plz check my code and tell me what is wrong with it.
Its urgent
From my UI i am calling an method in Buisness layer
Which in turn call datalayer method.
That datalayer method cpnnects to database.
My UI Code

AdminListusers_BizLayer objAdmLstUsr = (AdminListusers_BizLayer)Activator.GetObject(typeo f(AdminListusers_BizLayer), "tcp://"+ConfigurationSettings.AppSettings["ConnectionPort"]+"/AMSPortalAdminListusers_BizLayer");


objAdmLstUsr.GetNumrecords(pstrLogin,ref intNumRecords);

My Biz layer code

AdminListusers_DalLayer objDal=new AdminListusers_DalLayer();



public void GetNumrecords(string pstrLogin,ref int intNumRecords)
        {
            objDal.GetNumrecords(pstrLogin,ref intNumRecords);
        }



My GataLayer Code

public void GetNumrecords(string pstrLogin,ref int intNumRecords)
        {
            SqlConnection objSql=new SqlConnection();
            try
            {
                objSql=GetConnection();
                objSql.Open();
                    SqlCommand objCommand = new SqlCommand("pr_sel_records", objSql);
                    //SqlCommand objCommand = new SqlCommand("pr_sel_records", mobjConn);
                    objCommand.CommandType = CommandType.StoredProcedure;

                    objCommand.Parameters.Add(new SqlParameter("@p_login", SqlDbType.VarChar, 20));
                    objCommand.Parameters["@p_login"].Value = pstrLogin;
                    SqlDataReader objReader1 = objCommand.ExecuteReader();

                    if (objReader1.Read())
                    {
                        intNumRecords = Convert.ToInt32(objReader1["num_records"]);
                    }

                    objReader1.Close();


            }
            catch(SqlException Ex)
            {
                throw Ex;
            }
            finally
            {
                objSql.Close();
                objSql.Dispose();
            }
        }
        public DataSet GetTotalNumber(string strSQL)
        {
            DataSet objDSRecs=new DataSet();

            SqlConnection objSql=new SqlConnection();
            try
            {
                objSql=GetConnection();
                objSql.Open();
                SqlDataAdapter objDataAdapter = new SqlDataAdapter(strSQL, objSql);

                objDataAdapter.Fill(objDSRecs, 0, 0, "NumRecords");
            }
            catch(SqlException Ex)
            {
                throw Ex;
            }
            finally
            {
                objSql.Close();
                objSql.Dispose();
            }
            return objDSRecs;

        }
        public void SelectAllUsersIf(string strSQL,ref DataSet objDS)
        {
            SqlConnection objSql=new SqlConnection();
            try
            {
                objSql=GetConnection();
                objSql.Open();
                SqlDataAdapter objDataAdapter = new SqlDataAdapter();
                objDataAdapter.SelectCommand = new SqlCommand(strSQL, objSql);
                objDataAdapter.Fill(objDS, "Users");
            }
            catch(SqlException Ex)
            {
                throw Ex;
            }
            finally
            {
                objSql.Close();
                objSql.Dispose();
            }

I am getting an error like this


An existing connection was forcibly closed by the remote host
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Source Error:


Line 95: public void GetNumrecords(string pstrLogin,ref int intNumRecords)
Line 96: {
Line 97: objDal.GetNumrecords(pstrLogin,ref intNumRecords);
Line 98: }
Line 99: public DataSet GetTotalNumber(string strSQL)


Source File: e:\unisys\ramsbizlayer\adminlistusers_bizlayer.cs Line: 97

Stack Trace:


[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
   System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage reqMsg, IMessage retMsg) +264
   System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData& msgData, Int32 type) +877
   RAMSBizLayer.AdminListusers_BizLayer.GetNumrecords (String pstrLogin, Int32& intNumRecords) in e:\unisys\ramsbizlayer\adminlistusers_bizlayer.cs: 97
   UnisysRAMS.adminlistusers.GetNumRecords(String pstrLogin) in c:\inetpub\wwwroot\unisystest\adminlistusers.aspx. cs:2106
   UnisysRAMS.adminlistusers.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\unisystest\adminlistusers.aspx. cs:2273
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573



Please anybody who knows about this please help me








Similar Threads
Thread Thread Starter Forum Replies Last Post
The underlying connection was closed: jhouse .NET Web Services 33 September 21st, 2011 04:26 PM
The underlying connection was closed: An unexpecte adabass .NET Framework 1.x 0 October 12th, 2007 08:56 PM
Connection being closed? Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 January 18th, 2007 04:18 AM
An existing connection was forcibly closed by the vsmarimuthu ASP.NET 1.0 and 1.1 Professional 6 October 4th, 2006 10:22 AM
Underlying connection was closed r_ganesh76 .NET Web Services 0 May 4th, 2006 04:49 AM





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