How we connect the sql server 2000 to the visual basic
please give me an example code for me.
Thank you for your time and consideration.
Public objConnection As New ADODB.Connection
Public Function ConnectToDatabase() As Boolean
On Error GoTo ErrorConnection
If objConnection.State = adStateClosed Then
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=strUserId;password=strPassword;Initial Catalog=DatabaseName;Data Source=(local)"
End If
Exit Function
ErrorConnection:
MsgBox " Connection Not Opened. Error" & Err.Number & " - " & Err.Description, vbCritical + vbOKOnly
End Function