Hello all I am new to the community and have been stumbing across a problem with my code. I have a program that is connecting to an oracle database. I am using the table adapter to fill a combobox to select a model. Then I am connecting to the database programically to return a max and min value based on the selected model. I am doing this by passing parameters back with the selected mode. This all works fine.

Here is my problem:
I am wanting to query the database now with the specific model and selection. I have the query set up and the parameters passed back. Now I need to fill this information into a datagridview. I understand how to do this directly with the table adapters but the table adapters do not fulfill my needs at the moment.
I am having a lot of trouble finding examples of the best way to go about doing this and I'm an intern with an absent supervisor for the week.

I assume that I have to fill a dataset and then pass it to the datagridview but having never worked with datagridview I am unsure of how to do this.

Any help would be appreciated and if more information is neccessary to diagnose the problem please let me know.

6 Years
Discussion Span
Last Post by starlight849

At it's simplest you just do this:

MyDatagridView.Datasource = MyDataTable 

You need to get it to refresh to show the changes

Try looking up datagridView class in Google for more details on the properties and some examples of using it.


VS2008+Access2007 database.

            Dim con As New OleDb.OleDbConnection
            con.ConnectionString = "Your connection string"
            'create a new oledb dataadapter
            Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM test", con)
            'create a new dataset
            Dim ds As New DataSet()
            'fill the datset
            'attach dataset to the datagrid
            DataGridView1.DataSource = ds.Tables(0)
            ds = Nothing
            da = Nothing
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, Me.Text)
        End Try
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.