Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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, 01:57 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



 
Old September 28th, 2006, 07:14 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I dont see anywhere in the code where you are calling your objAdminLstUsr object which, one would think, is where your error stems from.

In any case the server you are connecting to is closing the connections you are making to it. It might be a timeout issue but it could be a series of things.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old September 28th, 2006, 07:25 AM
Registered User
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi dparsons,
thanks for ur reply,
U can see that in my UI page i am calling that objAdmLstUsr.
Another ont hing when i test this code in our local company machine its working well and good.
but when we deploy this in or client machine then only its showing error like this.
One more point for ur note.
After login i am redirecting to an page.
In that page some methods where i am calling the databse connections are working well but some methods only throwing exception like this.
Its very difficult for me to fix this issue.
If u want more details i will provide u.
It would be very helpfull for me if u advice me to clear this bug
Thankx

 
Old September 28th, 2006, 07:38 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am curious, why are you using sockets to connect to a machine?

What do you mean by "client" machine? Is that your outward facing Web Server?



--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old September 29th, 2006, 10:05 AM
Registered User
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I never Hardcode for socket.
I am just using TCP channel for Remoting and not HTTP.
But its throwing exception like that.
Client machine means the UI layer running machine.

 
Old September 29th, 2006, 12:34 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The server you are connecting to is closing the connection, however, I can not tell you why this is as it could be a multitude of reasons (your connection is timing out, etc.) Thats all i can tell you.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 4th, 2006, 10:22 AM
Registered User
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not all the methods which are trying to connect to database give me that exception.
Only some particlar methods throws this exception.
If i comment these methods then its working properly.
Still its a big problem for 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 2.0 Basics 0 September 28th, 2006 06:13 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.