Gss,
If you don't use Ado but AdoNet it is very simple
\\\
Dim Conn as new OleDB.OleDBconnection("TheConnectionString)
dim ad as new OleDb.OleDBDataAdapter("TheSelectString",Conn)
dim dt as new datatable
ad.fill(dt)
combobox1.DataSource = dt.defaultview
combobox1.Displaymember = "TheFieldYouWantToDisplay"
combobox1.Valuemember = "TheFieldYouWantToUse"
///
There is nothing to set to nothing or to dispose or whatever, that is done
automatic by the Garbage Collector, which is the reason that the name is
managed code.
This is just typed in the message so watch errors.
I hope this helps,
Cor
<gs*******@iol.itschreef in bericht
news:11*********************@i42g2000cwa.googlegro ups.com...
>i use Call CARICA_COMBO in ACTIVATE FORM (in vb classic) to fill a
comobox1 with data.
How to convert in VB.NET?
here the code in vb classic:
Sub CARICA_COMBO()
Dim cnt As New ADODB.Connection, rst As New ADODB.Recordset
cnt.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\GCD01F4500\DATI\PUBBLICA\INPS_WEB\USER.MD B;"
rst.Open "SELECT CAUSALI FROM SERVIZIO ORDER BY CAUSALI", cnt
Do Until rst.EOF
ComboBox1.AddItem rst.Fields("CAUSALI")
rst.MoveNext
Loop
Set rst = Nothing
Set cnt = Nothing
End Sub
tia.