DataTable gives error in WindowsForm with mysql (10.1.21-MariaDB)

139
February 09, 2018, at 11:08 PM

I want to show a table data in datagridview. I can insert (see bottom code), but select (see image -showData function) statement doesn't work!

cs code:

 string connectionString = "datasource=localhost;database=budgetmanagement;username=root;password=";
        string query = "SELECT * FROM works;";
        MySqlConnection conn = new MySqlConnection(connectionString);
        MySqlCommand cmd = new MySqlCommand(query, conn);
        conn.Open();
        MySqlDataAdapter adapter = new MySqlDataAdapter();
        adapter.SelectCommand = cmd;
        DataTable dTable = new DataTable();
        adapter.Fill(dTable);
        dataGridView1.DataSource = dTable;
        conn.Close();

This insert query works well:

 string MyConnection2 = "datasource=localhost;database=budgetmanagementcpa;username=root;password=";
        string Query = "insert into heads(head_name) values('" + this.name.Text + "');";
        MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
        MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
        MyCommand2.CommandTimeout = 200;
        MySqlDataReader MyReader2;
        MyConn2.Open();
        MyReader2 = MyCommand2.ExecuteReader();     
        name.Text = "";
        MessageBox.Show("Save Data");
READ ALSO
Spring Data JPA many-to-many unable to save records

Spring Data JPA many-to-many unable to save records

I have relatively simple domain objects:

160
PHP Having trouble with counting 4 data outputs

PHP Having trouble with counting 4 data outputs

im trying to get these to count 4 rows and then output a row div i already tried foreach but it didnt work and i think its because the while element but when someone can help me it would be appreciated

115
What are the differences between a view and a zero-argument procedure?

What are the differences between a view and a zero-argument procedure?

In mySQL, I often happen to hesitate between creating a view and creating a stored procedure that doesn't have any argument

78