Re: ExecuteScalar closes connection
From: Angel Saenz-Badillos[MS] (angelsa_at_online.microsoft.com)
Date: 07/27/04
- Next message: DaVbGuy: "RE: datagrid without dataset"
- Previous message: William \(Bill\) Vaughn: "Re: Retrieving DataReader data"
- In reply to: Yurcus: "Re: ExecuteScalar closes connection"
- Next in thread: Yurcus: "Re: ExecuteScalar closes connection"
- Reply: Yurcus: "Re: ExecuteScalar closes connection"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 27 Jul 2004 11:09:10 -0700
Yurcus, this should not be happening. The only reason I can think of is that
your execute command causes a very high severity exception on the server.
What version of the framework are you using? Do you have a stand alone
repro?
Thanks,
-- Angel Saenz-Badillos [MS] Managed Providers This posting is provided "AS IS", with no warranties, and confers no rights.Please do not send email directly to this alias. This alias is for newsgroup purposes only. I am now blogging about ADO.NET: http://weblogs.asp.net/angelsb/ "Yurcus" <Yurcus@discussions.microsoft.com> wrote in message news:675E93EC-BCD6-42CD-BE04-4C444C851997@microsoft.com... > cmd.CommandText = "SELECT count(name) FROM dbo.sysobjects " + > "WHERE xtype 'U' AND name = '" + tablename + "'; > int chk = Convert.ToInt32(cmd.ExecuteScalar()); > if(outDBConnection.State == ConnectionState.Closed) > outDBConnection.Open(); > > Sometimes after executing cmd.ExecuteScalar the connection is closed, sometimes it is not and i cannot come up with a rule of why it happens so i just check it every time and reopen my connection is nessesary. > cmd and oudDBConnections are declared as IDBCommand and IDBConnection because my program must be able to connect to Oracle MSDE or Access. > In this case my variables are instantiated with SQLConnection and SQLCommand. > > Thanks > > "Miha Markic [MVP C#]" wrote: > > > Hi Yurcus, > > > > What do you mean by closes the connections? > > The SqlConnection or physicall connection? > > Can you show us a piece of the code? > > > > -- > > Miha Markic [MVP C#] - RightHand .NET consulting & development > > miha at rthand com > > www.rthand.com > > > > "Yurcus" <Yurcus@discussions.microsoft.com> wrote in message > > news:B2E98E1B-71D6-4C9E-9D2A-898DBF94E26B@microsoft.com... > > > Hi, > > > I have noticed that sometimes ExecuteScalar closes underlying connection. > > > My command object is delared as IDBCommand but instansiated with > > SQLCommand. I am connecting to MSDE2000. > > > My ExecuteScalar is called in the initialization of my app so all > > conditions (such as usage history) are supposed to be same but sometimes it > > closes my connection, sometimes not. > > > Has anyone encountered the same problem? Anyone can explain this or this > > is a bug?? > > > have fun:) > > > > > >
- Next message: DaVbGuy: "RE: datagrid without dataset"
- Previous message: William \(Bill\) Vaughn: "Re: Retrieving DataReader data"
- In reply to: Yurcus: "Re: ExecuteScalar closes connection"
- Next in thread: Yurcus: "Re: ExecuteScalar closes connection"
- Reply: Yurcus: "Re: ExecuteScalar closes connection"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|