hi
i m making a c# app which reads data from ms accesss & display it in textbox i have tried the following method but that didn't worked suggest me smthing or correct my code pls

 myconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\nature bliss\Desktop\Stock\section1.accdb;Persist Security Info=False");
                        try
                        {
                            OleDbCommand cmd = new OleDbCommand();
                            cmd.Connection = myconn;
                            cmd.CommandText = "select * from section1";

                            myconn.Open();
                            //MessageBox.Show("Sucessfully Connected to " + myconn.DataSource.ToString());
                            var reader = cmd.ExecuteReader();
                            while (reader.Read())
                            {
                                textBox1.Text = reader["Name"].ToString();
                            }


                            myconn.Close();


                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(""+ex);
                        }
                        finally
                        {
                            myconn.Close();
                        }

How did it not work? Need a bit more information to go on.

The only suggestion I can make now is that your query isn't returning any rows.

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.