Connection between Visual Basic 6.0 project and SQL Server 2008

Please provide code for connecting a project developed in Visual Basic 6.0 with SQL Server 2008.
ShreyaTrivediAsked:
Who is Participating?
 
JR2003Connect With a Mentor Commented:
Note that

adPromptAlways = 1

so you could just write:


Private m_MyDb As Object

Public Function Connect() As Boolean

    On Error GoTo Trap

    Set m_MyDb = CreateObject("ADODB.Connection")
    With m_MyDb
        .Properties("Prompt") = 1
        .Open
        Connect = True
        'Debug.Print .ConnectionString
    End With

    GoTo SkipTrap

Trap:

    Connect = False

SkipTrap:

End Function
0
 
dportasCommented:
There is example code here:
http://msdn2.microsoft.com/en-us/library/aa905872.aspx

Legacy code should in general still work with SQL Server 2008. However, there are newer connection options such as the Native Client driver. There are also new features that may not be well tested or documented for VB6. That doesn't mean they won't work but you may not get support from Microsoft for some issues because VB6 is no longer in mainstream support.
0
 
JR2003Commented:
you can use ODBC:




Private m_MyDb As Object

Public Function Connect() As Boolean

    On Error GoTo Trap

    Set m_MyDb = CreateObject("ADODB.Connection")
    With m_MyDb
        .Properties("Prompt") = adPromptAlways
        .Open
        Connect = True
        'Debug.Print .ConnectionString
    End With

    GoTo SkipTrap

Trap:

    Connect = False

SkipTrap:

End Function
0
All Courses

From novice to tech pro — start learning today.