我第一次用组件开发网站,遇到最大的问题就是数据库连接的问题,连接总是会被其它的访问者关闭,我觉得不同的进程是不会相互干扰的,你们遇到什么棘手的问题吗
,大家讨论一下吧

解决方案 »

  1.   

    请访问:http://2004.ttzf.com/ 这是一个测试版如果你反复浏览,可能会出现类似
    ADODB.Connection error '800a0e78' 对象关闭时,不允许操作。 /inc/counthouse.asp, line 35 类似的错误,而且这个错误非常隐蔽,一刷新就不见了我到现在还没有搞定这个问题!
      

  2.   

    请大家贡献出你们的connection 类,让我研究一下
      

  3.   

    没看出什么错show us your connection object
      

  4.   

    Option Explicit
    Private mServerName As String
    Private mDBName As String
    Private mUserName As String
    Private mTimeout As Integer
    Private mIsopen As Boolean
    Public g_Cnn As New Connection
    Public Property Let ServerName(ByVal vData As String)
        mServerName = vData
    End PropertyPublic Property Let DBName(ByVal vData As String)
        mDBName = vData
    End PropertyPublic Property Let UserName(ByVal vData As String)
        mUserName = vData
    End PropertyPublic Property Let Timeout(ByVal vData As Integer)
        mTimeout = vData
    End PropertyPublic Property Get Isopen() As Boolean
        Isopen = mIsopen
    End PropertyPublic Function Cnn_DB() As Boolean
    'On Error GoTo ErrPlc1
    'On Error Resume Next
        Const strPwd = "xxxxxxx"
        g_Cnn.CursorLocation = adUseClient
        g_Cnn.CommandTimeout = mTimeout
        g_Cnn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=" _
                      & mUserName & ";Initial Catalog=" & mDBName & ";Data Source=" _
                    & mServerName & ";pwd=" & strPwd
        
        g_Cnn.Open
        
        'Call sound(1)
        Cnn_DB = True
        
    'Exit Function
    '
    'ErrPlc1:
    '
    '    If Err.Number = 3705 Then
    '        g_Cnn.Close
    '        g_Cnn.Open
    '        Cnn_DB = True
    '        'Beep
    '    Else
    '        Cnn_DB = False
    '    End If
                
    End FunctionPublic Function Close_DB() As Boolean
    ''On Error GoTo ErrPlc2
    'On Error Resume Next
    '    g_Cnn.Close
    '    Set g_Cnn = Nothing
    '    'Call sound(2)
    '    Close_DB = True
          If g_Cnn.State <> 0 Then
            g_Cnn.Close
            Set g_Cnn = Nothing
          End IfEnd Function
      

  5.   

    http://www.csdn.net/develop/read_article.asp?id=22628
    这种方式看看这个我倒没有想过