Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    slooow response on web app (ASP.NET, VS 2008 Pro, .Net 2+)

    i noticed a lot of timeout issues in my web app and am wondering if there's a better way to get the data. the basic code for pulling the data is
    <font face="Georgia">
    conn.Open()

    Dim dgTable As New DataTable
    dgTable.Load(myCmd.ExecuteReader(CommandBehavior.C loseConnection))

    dg_AddressData.DataSource = dgTable
    dg_AddressData.DataBind()
    </font face=georgia>

    this is in a development enviornment and my connection string to SQL Server is explicit (that is, written out in code rather than referenced from web.config) and uses new SqlConnection. the connection works off a stored proc. when i run the same query directly in SQL Server Management Studio, it runs quickly, but ASP.NET is elderly and dim.

    any ideas?

    TIA

  2. #2
    New Lounger
    Join Date
    Sep 2009
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm assuming you are using VB.NET, not C#. I included this example in VB.NET to show how I do it. I tend to use a lot of Using statements because they will automatically close connections, data readers, etc as well as remove the reference. This ran in a matter of milliseconds. Try something like this and let me know if it's any faster.

    Code:
    Sub Main()
    		Dim connectionString As String = "Data Source=localhost;Initial Catalog=Development;User Id=xxx;Password=xxx;"
    		Dim query As String = "SELECT * FROM Employees"
    		' Dim reader As SqlDataReader
    
    		Using connection As New SqlConnection(connectionString)
    			Using command As New SqlCommand(query, connection)
    				Try
    					connection.Open()
    					Using reader As SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
    					End Using
    				Catch ex As SqlException
    					Console.WriteLine(ex.Message)
    				End Try
    			End Using
    		End Using
    
    		Console.WriteLine("Done!")
    	End Sub

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help but honestly i can't remember what exactly the issue was. since posting, I completed the project and even migrated it to DotNetNuke, where it has languished for months. "Code Review" my be a synonym for something else around here...

    anyhow, my finished project used stored procs and DataTables or DataSets from the fill(), depending on the need. Performance did improve, but can't remember what the issue was.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •