Results 1 to 6 of 6

Thread: Allow to select title from comboBox then display for the select title

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Allow to select title from comboBox then display for the select title

    Hi..

    I have one problem...

    how to allow the user to select title from comboBox then display acording for the select title to the textbox...

    I read that need to create two data Adapters...

    I configure one with the SQl statement:

    Select TItle, Author, ISBN FROM Books
    WHERE Title = ?

    But how to configure the other data adapter?

    When i run with only one data Adapter, i get the error:

    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

    The error point to the code below Private Sub frmBooks_load(....
    ......dbRnR.Fill(DsBooks1) =error

    Thanks

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    this one?
    VB Code:
    1. Dim cn As New SqlConnection("integrated security=true;initial catalog=northwind;data source=...")
    2.     Dim da As New SqlDataAdapter("select * from sampletable", cn)
    3.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Dim dt As New DataTable()
    5.         da.Fill(dt)
    6.         Dim dr As DataRow
    7.         For Each dr In dt.Rows
    8.             ComboBox1.Items.Add(dr(1))
    9.         Next      
    10. End Sub
    11.  
    12.  Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    13.         TextBox1.Text = ComboBox1.SelectedItem
    14.     End Sub

  3. #3

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Wink Allow to select title from comboBox then display for the select title

    Thanks...

    But i used OleDbConnection to connect not SqlConnection..
    and i used the data Adapter wizard to edit th SQL code...

    is it still the same code to use ?....

    This is the code i write into...
    Code:
    Private Sub frmBooks_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                  
            'dbRnR.Fill(DsBooks1)    'error pointed when running
            DisplayRecordPosition()
        End Sub
    
     
    Private Sub cboTitle_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTitles.SelectedIndexChanged
            
            DsBooks1.Clear()
            dbRnR.SelectCommand.Parameters("Title").Value = cboTitles.Text
            dbRnR.Fill(DsBooks1)
        End Sub
    Last edited by toytoy; Dec 3rd, 2004 at 08:28 AM.

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    its just they same..
    just change the sql to oledb

  5. #5

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Wink

    Hi...

    How come still cannot....

    i change the sql to ole and run....

    It states that both connection and adapter are not defined..

    Thanks

  6. #6
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    VB Code:
    1. Imports System.Data.OleDb

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