Windows Form and MySQL C#

  • Thread starter Thread starter LikeMrYassine
  • Start date Start date
L

LikeMrYassine

Guest
Hey

Im trying to make a application can show MySQL Tables -> rows using

dataGridView1.DataSource

But its dont show anything when i click the button :/

i tested if its send Query and its work good but its not showing MySQL Tables ( rows ) btw this is my code :

if (this.OpenConnection() == true)
{
try
{
string sql = "SELECT * FROM `" + table.Text + "`"; // set query to fetch data "Select * from tabelname";
DataSet s = new DataSet();
MySqlDataAdapter ds = new MySqlDataAdapter(sql, connection);
MySqlCommandBuilder k = new MySqlCommandBuilder(ds);
ds.Fill(s, table.Text);
dataGridView1.DataSource = s.Tables[table.Text];
s.Dispose();
this.connection.Close();

}
catch (Exception z)
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\ProgramData\SAPMySQL\logs.txt", true))
{
string og;
og = "[MySQL Error]:" + z.Message;
file.WriteLine(thisDay.ToString() + og);
file.WriteLine("");
if (og == "[MySQL Error]:Character set utf16 is not supported")
{
MessageBox.Show("All Rows now showen!", "SAP MySQL: Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Fatal Error: 0x0DDF5FFt Unable to Load Query\n" + og, "SAP MySQL: Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}


Thank You in advence :)

Yassine

Continue reading...
 
Back
Top