0

This should be simple and its just not working. Below code manually creates the datatable and then tries to use adapter.fill method. You can even see commented out code where I manually do an insert of the exact same data, that works just fine. When I use the adapter.fill method, I don't get an error, an exception, anything. It just doesn't work, no data in the table.

            DataTable testdt = new DataTable();
            testdt.Columns.Add("test");
            DataRow testRow = testdt.NewRow();
            testRow[0] = "testing";
            testdt.Rows.Add(testRow);

            MySqlConnection conn = new MySqlConnection(txtDBConnString.Text);
            conn.Open();

            /*MySqlCommand comm = conn.CreateCommand();
            comm.CommandText = "INSERT INTO test(test) VALUES('testing')";
            comm.ExecuteNonQuery();
            conn.Close();*/

            MySqlDataAdapter myadapter = new MySqlDataAdapter();
            myadapter.SelectCommand = new MySqlCommand("select * from test", conn);
            myadapter.Fill(testdt);

0 Answers0