List Info

Thread: Is this SP call correct




Is this SP call correct
user name
2006-08-01 19:35:53
Finally
             If Not objConn Is Nothing Then
                 objConn.Dispose()
             End If

             If Not objCmd Is Nothing Then
                 objCmd.Dispose()
             End If
End Try
------------------------

Also.. BindData().. what does that do?  Is this one
function?  Or is it in
the page_Load?


On 8/1/06, David Caver <dkcavergrandecom.net> wrote:
>
> I've got the objConn.Close in the Finally statement so
I'm assuming they
> are. Is there a way I can look in SQL to see how many
connections are open
> or is they aren't getting closed?
>
> My next step is to try to figure out what is going on
with the Server.
> Looking in Task Mgr, the CPU is usually around 1% or so
and I haven't seen
> it go over about 14%. So, I don't think the server is
getting pegged.
>
> When I see the slowness on the pages I can run the SP
that is on that page
> directly in Studio Mgr and it returns in less than a
second.
>
> If I reboot the server, the speed comes back. This is
what is leading me
> to
> think it may be something going on with the
connections.
>
> David
>
> -----Original Message-----
> From: jlyndsgmail.com [mailto:jlyndsgmail.com] On Behalf Of Joe Lynds
> Sent: Tuesday, August 01, 2006 10:52 AM
> To: aspnet-databasesaspadvice.com
> Subject: [aspnet-databases] RE: Is this SP call correct
>
> Are the connections being closed?
>
> I've had this sort of problem when excessive numbers
of connections
> accumulate.
>
> Also, you can declare your connection like this:
> dim objConn as new SqlConnection(connString)
>
> -Joe
>
> On 8/1/06, David Caver <dkcavergrandecom.net> wrote:
> >
> > We just switched over to a production SQL 2005
server and at first
> > everything was going great. Now I'm starting to
see slowness in the
> > response
> > of my pages on a specific site. I also just
recently started using the
> > Finally section on my Try.Catch. I wanted to make
sure that this looks
> > correct because in the Finally section I'm
getting the green underlines
> > for
> > the objConn and objCmd saying that the variable is
being used before it
> is
> > assigned a value. I'm wondering if this isn't
working like I think it
> > should
> > and my connections aren't getting closed.
> >
> >
> >
> > Should I be making my SP calls this way?
> >
> >
> >
> >
> >
> >
> >
> > Dim connString As String
> >         Dim objConn As SqlConnection
> >         Dim objCmd As SqlCommand
> >         Try
> >             connString =
> > ConfigurationManager.ConnectionStrings
> > ("ConnectionString").ConnectionString
> >             objConn = New
SqlConnection(connString)
> >             objConn.Open()
> >
> >
> >
> >             objCmd = New
SqlCommand("AdminCustomerAdd", objConn)
> >             objCmd.CommandType =
CommandType.StoredProcedure
> >             objCmd.Parameters.Add(New
SqlParameter("CustID",
> > SqlDbType.Int))
> >             objCmd.Parameters("CustID").Value =
Session("AdminCustID")
> >             objCmd.ExecuteNonQuery()
> >             objConn.Close()
> >             objConn.Dispose()
> >
> >
> >
> >             BindData()
> >
> >
> >         Catch ex As Exception
> >             pnlFailed.Visible = True
> >             lblFailed.Text = "Error: "
& ex.Message.ToString
> >             lblFailed.Visible = True
> >
> >
> >
> >         Finally
> >             If Not objConn Is Nothing AndAlso Not
(objConn.State =
> > ConnectionState.Closed) Then
> >                 objConn.Close()
> >                 objConn.Dispose()
> >             End If
> >
> >
> >
> >             If Not objCmd Is Nothing Then
> >                 objCmd.Dispose()
> >                 objCmd = Nothing
> >             End If
> >
> >
> >         End Try
> >
> >
> >
> >
> >
> >
> >
> >
> > Need SQL Advice? http://sqladvice.com
> > Need RegEx Advice? http://regexadvice.com
> > Need XML Advice? http://xmladvice.com
> >
>
>
>
> --
>
> http://www.jlion.com
>
>
>
> Need SQL Advice? http://sqladvice.com
> Need RegEx Advice? http://regexadvice.com
> Need XML Advice? http://xmladvice.com
>
>
>
>
>
>
> Need SQL Advice? http://sqladvice.com
> Need RegEx Advice? http://regexadvice.com
> Need XML Advice? http://xmladvice.com
>



Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )