zoukankan      html  css  js  c++  java
  • SQL2000数据库升级为SQL2012_SQL SERVER 2012/2014正确链接到SQL SERVER 2000的方法,

    Option Explicit
    
    Private Sub cmdCancel_Click()
        MySql = "CANCEL"
        Unload Me
    End Sub
    
    Private Sub cmdOK_Click()
        LocalComputerName = txtComputerName
        LocalDataBaseName = txtDatabaseName
        LocalDatabaseLogin = txtDatabaselogin
        LocalDatabasePassword = txtDatabasePassword
        LocalDataBaseType = XTCombo(1).Text
        RemoteComputerName = NetComputerName
        RemoteDataBaseName = NetDatabaseName
        RemoteDatabaseLogin = NetDatabaselogin
        RemoteDatabasePassword = NetDatabasePassword
        XITONGSZ.XTSZ(7).Text = txtComputerName
        XITONGSZ.XTSZ(8).Text = txtDatabaseName
        XITONGSZ.XTCombo(1).ListIndex = XTCombo(1).ListIndex
        XITONGSZ.XTSZ(9).Text = NetComputerName
        XITONGSZ.XTSZ(10).Text = NetDatabaseName
        XITONGSZ.XTCombo(2).ListIndex = XTCombo(0).ListIndex
        
    '    SaveSetting APP_CATEGORY, App.Title, "本机服务器", LocalComputerName
    '    SaveSetting APP_CATEGORY, App.Title, "本机数据库", LocalDataBaseName
    '    SaveSetting APP_CATEGORY, App.Title, "本机数据库登录", LocalDatabaselogin
    '    SaveSetting APP_CATEGORY, App.Title, "本机数据库口令", LocalDatabasePassword
    '    SaveSetting APP_CATEGORY, App.Title, "数据库类型", LocalDataBaseType
    '
    '    SaveSetting APP_CATEGORY, App.Title, "网络服务器", RemoteComputerName
    '    SaveSetting APP_CATEGORY, App.Title, "网络数据库", RemoteDataBaseName
    '    SaveSetting APP_CATEGORY, App.Title, "网络数据库登录", RemoteDatabaselogin
    '    SaveSetting APP_CATEGORY, App.Title, "网络数据库口令", RemoteDatabasePassword
    '    SaveSetting APP_CATEGORY, App.Title, "数据库类型", RemoteDataBaseType
        
        MySql = "OK"
        Unload Me
    End Sub
    
    Private Sub Command1_Click()
    On Error Resume Next
    Dim DataBaseConnectString As String
        
        Select Case XTCombo(1).Text
        Case "ACCESS"
            DataBaseConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & txtDatabaseName
        Case "SQL_2000"
            DataBaseConnectString = "Provider=SQLOLEDB.1;Password=" & txtDatabasePassword & ";Persist Security Info=True;User ID=" & txtDatabaselogin & ";Initial Catalog=" & txtDatabaseName & ";Data Source=" & txtComputerName
        Case "SQL_2008"
            DataBaseConnectString = "Provider=SQLNCLI10.1;Server=" & txtComputerName & ";Database=" & txtDatabaseName & ";Uid=" & txtDatabaselogin & "; Pwd=" & txtDatabasePassword & ";"
        Case "ORACLE"
            DataBaseConnectString = "Provider=MSDASQL.1;Password=gzsf;Persist Security Info=True;User ID=gzguest;Data Source=" & txtComputerName
        Case "SYBASE"
            
        Case Else
            DataBaseConnectString = ""
        End Select
        Err.Clear
        With RemoteCn
            .ConnectionString = DataBaseConnectString
            .CursorLocation = adUseClient
            .Mode = adModeReadWrite
            .ConnectionTimeout = 10
            .Open
        End With
        If Err.Number Then
            Err.Clear
            MsgBox "数据库连接不成功!请检查!", vbOKOnly, "友情提示"
        Else
            MsgBox "数据库连接成功!祝贺您!", vbOKOnly, "友情提示"
        End If
        RemoteCn.Close
    End Sub
    
    Private Sub Command2_Click()
    On Error Resume Next
    Dim DataBaseConnectString As String
        
        Select Case XTCombo(0).Text
        Case "ACCESS"
            DataBaseConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & NetDatabaseName
        Case "SQL_2000"
            DataBaseConnectString = "Provider=SQLOLEDB.1;Password=" & NetDatabasePassword & ";Persist Security Info=True;User ID=" & NetDatabaselogin & ";Initial Catalog=" & NetDatabaseName & ";Data Source=" & NetComputerName
        Case "SQL_2008"
            DataBaseConnectString = "Provider=SQLNCLI10.1;Server=" & NetComputerName & ";Database=" & NetDatabaseName & ";Uid=" & NetDatabaselogin & "; Pwd=" & NetDatabasePassword & ";"
        Case "ORACLE"
            DataBaseConnectString = "Provider=MSDASQL.1;Password=gzsf;Persist Security Info=True;User ID=gzguest;Data Source=" & NetComputerName
        Case "SYBASE"
        
        Case Else
            DataBaseConnectString = ""
        End Select
        Err.Clear
        With RemoteCn
            .ConnectionString = DataBaseConnectString
            .CursorLocation = adUseClient
            .Mode = adModeReadWrite
            .ConnectionTimeout = 10
            .Open
        End With
        If Err.Number Then
            Err.Clear
            MsgBox "数据库连接不成功!请检查!", vbOKOnly, "友情提示"
        Else
            MsgBox "数据库连接成功!祝贺您!", vbOKOnly, "友情提示"
        End If
        RemoteCn.Close
    
    End Sub
    
    Private Sub Form_Load()
        txtComputerName = LocalComputerName
        txtDatabaseName = LocalDataBaseName
        txtDatabaselogin = LocalDatabaseLogin
        txtDatabasePassword = LocalDatabasePassword
        XTCombo(1).Text = LocalDataBaseType
        
        NetComputerName = RemoteComputerName
        NetDatabaseName = RemoteDataBaseName
        NetDatabaselogin = RemoteDatabaseLogin
        NetDatabasePassword = RemoteDatabasePassword
        XTCombo(0).Text = RemoteDataBaseType
        
    End Sub
    
    Private Sub Text2_Change()
    
    End Sub
    

     自SQL Server 2012开始,已经不支持通过链接服务器链接到SQL Server 2000。主要是SQL SERVER 2012/2014安装的是SQL Server Native Client 11.0。而SQL Server Native Client 11.0 does not support connections to SQL Server 2000 or earlier versions。 

    需要安装SQL Server Native Client 10. 

  • 相关阅读:
    asp.net core MVC 入门学习
    C# 中关于重载与重写的区别及用法
    C# 生成随机的6位字母,包含大小写
    C# CheckBoxList绑定值,设置及获取
    jquery中checkbox的全选与反选
    docker 执行 docker system prune 导致Azure Devops build镜像失败
    Navicat 连接mysql 报错: Authentication plugin caching_ sha2_password cannot be loaded
    docker build 错误 /usr/share/dotnet/sdk/2.1.801/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference
    Azure Devops: COPY failed: stat /var/lib/docker/tmp/docker-builder268095359/xxxxxxx.csproj no such file or directory
    Azure DevOps vsts-agent-linux 安装出错, Must not run with sudo
  • 原文地址:https://www.cnblogs.com/xiongwei/p/14403331.html
Copyright © 2011-2022 走看看