fill combobox1...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gss.italy@iol.it

    #1

    fill combobox1...

    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.Connectio n, rst As New ADODB.Recordset

    cnt.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
    "Data Source=\\GCD01F 4500\DATI\PUBBL ICA\INPS_WEB\US ER.MDB;"
    rst.Open "SELECT CAUSALI FROM SERVIZIO ORDER BY CAUSALI", cnt

    Do Until rst.EOF
    ComboBox1.AddIt em rst.Fields("CAU SALI")
    rst.MoveNext
    Loop

    Set rst = Nothing
    Set cnt = Nothing

    End Sub

    tia.

  • Cor Ligthert [MVP]

    #2
    Re: fill combobox1...

    Gss,

    If you don't use Ado but AdoNet it is very simple

    \\\
    Dim Conn as new OleDB.OleDBconn ection("TheConn ectionString)
    dim ad as new OleDb.OleDBData Adapter("TheSel ectString",Conn )
    dim dt as new datatable
    ad.fill(dt)
    combobox1.DataS ource = dt.defaultview
    combobox1.Displ aymember = "TheFieldYouWan tToDisplay"
    combobox1.Value member = "TheFieldYouWan tToUse"
    ///

    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.italy@iol. itschreef in bericht
    news:1156973542 .182978.65130@i 42g2000cwa.goog legroups.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.Connectio n, rst As New ADODB.Recordset
    >
    cnt.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
    "Data Source=\\GCD01F 4500\DATI\PUBBL ICA\INPS_WEB\US ER.MDB;"
    rst.Open "SELECT CAUSALI FROM SERVIZIO ORDER BY CAUSALI", cnt
    >
    Do Until rst.EOF
    ComboBox1.AddIt em rst.Fields("CAU SALI")
    rst.MoveNext
    Loop
    >
    Set rst = Nothing
    Set cnt = Nothing
    >
    End Sub
    >
    tia.
    >

    Comment

    Working...