3
Contributors
4
Replies
14
Views
7 Years
Discussion Span
Last Post by AndreRet
2

first, Add reference before do all codes..
Click on Project->Reference, Find for Microsoft ActiveX Data Object 2.5 Library and select it.

this followwing code to connect vb6 with MS SqlServer
Create 1 button on your form

Public Con As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Command1_Click()
If Con.State = 1 Then Con.Close
    Con.ConnectionString = "Provider=MSDASQL;Driver={SQL Server}; " & _
    " SERVER=USER;Database=Test;Uid=;Pwd="
    Con.Open
MsgBox "VB6 has connected with SQLServer Database"

Con.Close
End Sub
Votes + Comments
thx ;)
1

Also note that your other posts using the recordset (rsAddNew) uses the conn as the connection. You need to change that to Con if you use JX's connection because the connection is called Con.:)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.