Results 1 to 5 of 5

Thread: Form with 2 combobox.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    IL
    Posts
    156

    Question Form with 2 combobox.

    Hello folks i have this question:

    if i use dataset to fill my combobox by SQLStatment and i need to fill 2 seperate combos to i need to datasets?

    VB Code:
    1. Dim dsPhoneArea As New DataSet
    2.         Dim odaPhoneArea As OleDb.OleDbDataAdapter
    3.         Dim strSql As String = "Select Area FROM tblPhoneAreas where ID = '00'"
    4.         Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= db.mdb"
    5.  
    6.         Try
    7.             Me.odcFirstContact.ConnectionString = strConn
    8.             '   MsgBox("tried")
    9.              
    10.         Catch eConnection As System.Exception
    11.             MessageBox.Show(eConnection.Message + " Please contact SQVision team for technical support.", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    12.         End Try
    13.         '[Change dbconnection to application startup path/]
    14.  
    15.         '[Load phone areas into combobox]
    16.         Try
    17.             odaPhoneArea = New OleDb.OleDbDataAdapter(strSql, strConn)
    18.             odaPhoneArea.Fill(dsPhoneArea, "tblPhoneAreas")
    19.             cmbPhoneArea.DataSource = dsPhoneArea.Tables("tblPhoneAreas")
    20.             cmbPhoneArea.DisplayMember = "Area"
    21.             dsPhoneArea.Clear()
    22.             strSql = "Select Area FROM tblPhoneAreas where ID = '01'"
    23.  
    24.             odaPhoneArea = New OleDb.OleDbDataAdapter(strSql, strConn)
    25.  
    26.             odaPhoneArea.Fill(dsPhoneArea, "Area")
    27.             cmbCellArea.DataSource = dsPhoneArea.Tables(0)
    28.             cmbCellArea.DisplayMember = "Area"
    29. end try

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    IL
    Posts
    156

    UNRESOLVED

    ok ok im not following....
    so i need two datasets or i can use one,
    cuz with this code it just fill the both combobox with the same data...

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    if i use dataset to fill my combobox by SQLStatment and i need to fill 2 seperate combos to i need to datasets?
    No, you don't need to use two datasets.

    What is it you are trying to do? That may clarify what you are really trying to get answered.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    IL
    Posts
    156
    I have table with phone areas and its ID

    all cell phone ares marked with ID 01
    and usual phone marked with ID 00
    for example cell areas are:

    id=01 area=050
    id=01 area=053


    and phone:

    id=00 area=02
    id=00 area 03.


    on my form i have two combos one must contain cell areas and the other must contain phone areas.
    i used the code that i posted on my first messege, and it fill me with cell areas only.
    how can i solve it without using two datasets?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width