搜索: 标题内容作者  
  首页VB.NET教程VB.NET外文资料
背景:
阅读新闻

Timeout Expired

[日期:2007-12-09]   来源:xtradeonline.com  作者:未知   [字体: ]
    新闻简介:Here is a code snippet that I use quite frequently when I need info from my database in table form:
    Dim oPartsConn As New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString-Parts"))
    Dim daParts As OleDbD
        关 键 词:   vb.net  SQL 

Here is a code snippet that I use quite frequently when I need info from my database in table form:

    Dim oPartsConn As New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString-Parts"))
    Dim daParts As OleDbDataAdapter
    Dim dtParts As New DataTable
    oPartsConn.Open()
    sSQL = "SELECT * FROM Parts" 
    dtParts.Clear()
    If Not Me.daParts Is Nothing Then Me.daParts.Dispose()
    daParts = New OleDbDataAdapter(sSQL, oPartsConn)
    daParts.MissingSchemaAction = MissingSchemaAction.AddWithKey
    daParts.AcceptChangesDuringFill = False
    daParts.Fill(dtParts)

Of course, the sSQL can have any SELECT statement in it, and I encountered a problem when I was using this snippet with a particularly complicated SELECT.  I kept getting a "Timeout Expired." error in the Catch portion of the Try-Catch surrounding this snippet.

Here's the solution:  Add this line before the .Fill line:

    daParts.SelectCommand.CommandTimeout = 300 

If you believe an article violates your rights or the rights of others, please contact us.

收藏 推荐 打印 | 录入:admin | 阅读:
相关新闻      
友情链接
本文评论   [发表评论] 全部评论 (0)
赞助商广告
热门评论