Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have an access database composed of tables day-morning, swing-afternoon, and grave-night. i want to have a combobox that have those table, for example i choose day-morning in the combobox and i will click the search button then the fields and data that saved on the day-morning table will show up in a datagridview. how can i do that? i dont have an idea. please help me. this is for my project. I need it asap. thankyou for those who will help me.

[Edit]
the only table that is showing in the data grid view was the grave-night. why is that? I only input the items in the combobox it is not connected to my access database is that ok?

Here is my code

VB
MyConn = New OleDBConnection
    MyConn.ConnectionString = connString
    ds = New DataSet
    tables = ds.Tables
    
    If Combobox1.text = "day-morning" Then
        da = New OleDBDataAdapter("Select * FROM [day-morning]", MyConn)
        da.Fills(ds,"day-morning")
        Dim view As New DataView(tables(0))
        source1.datasource = view
        DataGridView1.DataSource = view
    ElseIf Combobox1.text = "swing-afternoon" Then
        da = New OleDBDataAdapter("Select * FROM [swing-afternoon]", MyConn)
        da.Fills(ds,"swing-afternoon")
        Dim view As New DataView(tables(0))
        source1.datasource = view
        DataGridView1.DataSource = view
    else : Combobox1.text = "grave-night"
        da = New OleDBDataAdapter("Select * FROM [grave-night]", MyConn)
        da.Fills(ds,"grave-night")
        Dim view As New DataView(tables(0))
        source1.datasource = view
        DataGridView1.DataSource = view
    end if
Posted
Updated 15-Jun-15 22:08pm
v5
Comments
[no name] 15-Jun-15 21:24pm    
Sorry this is not how it works. You do your own research and then we may help you with specific problems. Email addresses are a no no. We don't respond to those either.
Member 11768334 15-Jun-15 22:15pm    
the only table that is showing in the data grid view was the grave-night. why is that? I only input the items in the combobox it is not connected to my access database is that ok?

here is my code



MyConn = New OleDBConnection
MyConn.ConnectionString = connString
ds = New DataSet
tables = ds.Tables

If Combobox1.text = "day-morning" Then
da = New OleDBDataAdapter("Select * FROM [day-morning]", MyConn)
da.Fills(ds,"day-morning")
Dim view As New DataView(tables(0))
source1.datasource = view
DataGridView1.DataSource = view
ElseIf Combobox1.text = "swing-afternoon" Then
da = New OleDBDataAdapter("Select * FROM [swing-afternoon]", MyConn)
da.Fills(ds,"swing-afternoon")
Dim view As New DataView(tables(0))
source1.datasource = view
DataGridView1.DataSource = view
else : Combobox1.text = "grave-night"
da = New OleDBDataAdapter("Select * FROM [grave-night]", MyConn)
da.Fills(ds,"grave-night")
Dim view As New DataView(tables(0))
source1.datasource = view
DataGridView1.DataSource = view
end if

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900