i dont know aany thing about adodb..
please help me..
please tell me the step by step way to connect the database with adodb in vb6, and to add and update..

Recommended Answers

All 4 Replies

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
commented: thx ;) +4

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.:)

Thanks Alot Jx and Andre....

It was a pleasure.:) Happy coding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.