VB6与SQLServer数据库连接实例ADO

Option Explicit

Dim gobjConn As New cADO 

Dim k As Integer
    
    k = gobjConn.Connected("数据库名称", "IP地址", "sa", "sa密码")
    If k = 0 Then
        Label1.Caption = Now() & "  连接--数据库服务器失败!"
        Label1.ForeColor = &H8000&
    Else
        Label1.Caption = Now() & "  与数据库连接成功!"
        Label1.ForeColor = &H8000&
    End If

连接数据库就是这么简单,同时支持vb.net,VB.NET先引用YYData.dll,vb6直接系统注册一下 regsvr32 YYData.dll

 

你可能感兴趣的:(VB6)