Starr Duskk
asked on
Timeout on SqlDataAdapter Fill to DataTable
I have a query that when run via sql server management studio, it takes 30 seconds. But when I run it within my source code to populate a DataTable, it errors with a timeout.
Here is my code that uses the query to populate the DataTable. It errors right after the Fill:
Is there something wrong with my code above that would cause the same query that runs successfully in SSMS to fail with a web project? It goes straight to the Finally block.
thanks.
Here is my code that uses the query to populate the DataTable. It errors right after the Fill:
Public Function GetDataTable(ByVal sql As String) As DataTable
Dim con As New SqlConnection(Name.GetConnectionString)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = New SqlCommand(sql, con)
Dim myDataTable As New DataTable()
con.Open()
Try
adapter.Fill(myDataTable)
Finally
adapter.Dispose()
con.Close()
End Try
Return myDataTable
End Function
Is there something wrong with my code above that would cause the same query that runs successfully in SSMS to fail with a web project? It goes straight to the Finally block.
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes that is fine as we'll.
ASKER
thanks!
Open in new window