This code works fine in VB6 to populate a few combo boxes from a couple of fields in a db. What is the equivalent of this in .NET?VB Code:
Private Sub Form_Load() Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection cn.ConnectionString = "Provider=SQLOLEDB.1;....." '<-- Full connection string cn.Open Set rs = New ADODB.Recordset With rs .ActiveConnection = cn .CursorLocation = adUseServer .CursorType = adOpenForwardOnly .LockType = adLockReadOnly .Source = "SELECT DISTINCT Titles, Authors From Books" .Open End With Do While Not rs.EOF cboTitles.AddItem rs!Titles & "" cboAuthors.AddItem rs!Authors & "" rs.MoveNext Loop rs.Close Set rs = Nothing cn.Close Set cn = Nothing End Sub




Reply With Quote