Visual Basic 6: Simple ADO Connection

Using SQL Server connection:

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Command1_Click()
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;
pwd=sales;Initial Catalog=Sellout;Data Source=ATLAS-LAPTOP\NISTA"
cn.Open
Dim TheString As String

TheString = "SELECT * FROM Klimakes"
rs.Open TheString, cn, adOpenKeyset, adLockOptimistic
While Not rs.EOF
Me.Text1.Text = rs.Fields("Klimaka_Description").Value
rs.MoveNext
Loop
rs.Close
cn.Close
End Sub

Leave a Reply