I keep getting this annoying error followed by a really long message when trying to retrieve and match data from database, here is the code

        try
        {
            string connection = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data Source=c:\Users\PC\Documents\Visual Studio 2013\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Main database.accdb";
            string Query = "SELECT * FROM [Firebird m0 Damage] WHERE textBox15= '" + comboBox6.SelectedIndex + "'";
            OleDbConnection me = new OleDbConnection(connection);
            OleDbCommand constr = new OleDbCommand(Query, me);

            me.Open();
            OleDbDataReader reader = constr.ExecuteReader();
            constr.Parameters.Add("Total price");

            while (reader.Read())
            {
              textBox15.Text = reader["Total price"].ToString();   
            }

            me.Close();
        }

        catch (Exception ex)
        {
            MessageBox.Show("Error " + ex);

        }   
    }

I have a datatable with 2 columns, parameter change and total price, i have also populated my combobox with the 1st column, when i select a value it should return data from the 2nd column but in the same row, however mine won't work

It seems to me you are adding a parameter called TotalPrice to your parameter collection but you never give it a value.
You can either use:
constr.Parameters.AddWithValue("Total price", 'Some value');

or
constr.Parameters.Add("Total price");
constr.Parameters["Total price"].value = some value

So what's the purpose of "Total Price"? If you are trying to pull it from the database, you do NOT need to add it to the params. I also point this out because you called the "ExecuteRead". That's what queries the Database, the read part is just reading what was loaded into memory from the query.

My guess is if it's blank, it's either not in the table, or for some reason adding the param wipes out any existing data (I could be wrong though).

Also, not sure how the referencing works under the layers, but you are adding the param to the command piece, but trying to reader from it from the reader, after you have performed your query

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.