[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1193
  • Last Modified:

SQl dataadapter timeout during fill method

I have a web page that loads data from a SQl server table.

Everytime the webpage loads it times out during the dataadapter.fill() function

This is what i tried.
1. Ran the same query in SQl server and it reurned the result set in 4 seconds.
2. Created a windows app with the same query and used a dataadapter to fill a dataset and diplay in grid. Worked in 5-6 seconds.
3. Increased the sqladapter.selectcommand.timout property to 0 and then the page never loads without any error displayed. only the non data part loads and the grid doent load.

This webpage worked fine when it was running on a webserver. But when i run it locally it timesout.

Public Function GetDataSet( s as String ) as DataSet
	if not CheckSql() then exit Function
	sqladapter = new SqlDataAdapter( sqlstr , conn )
	ds = new DataSet()
	sqladapter.Fill( ds , s )<<--- timeout
	Return( ds )
End Function

Open in new window

  • 2
2 Solutions
Check if the connection string is changed and is not pointing to the server on the internet.
isaackhaziAuthor Commented:
Yes i checked that.... its localhost...
Try setting the connection time out in the connection string
SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=123456;database=TestDB;Connection Timeout=90");
sqlAdapter.SelectCommand.CommandTimeout = 0; 

Open in new window


Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now