Home All Groups Group Topic Archive Search About
Author
30 Aug 2006 9:32 PM
gss.italy
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.MDB;"
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.

Author
31 Aug 2006 6:30 AM
Cor Ligthert [MVP]
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

<gss.it***@iol.it> schreef in bericht
Show quoteHide quote
news:1156973542.182978.65130@i42g2000cwa.googlegroups.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.MDB;"
> 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.
>