Hello:
I found an article to help me get connected to MySQL. (Using MySQL for testing only. Will eventually use MSSQL). http://www.c-sharpcorner.com/UploadFile/iamibohal/339/Default.aspx
It has a line: GridView1.DataBind();
Seems that that .DataBind() is not right. Can someone tell me what it should be or what I am missing?
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Mar 2, 2010, 2:43 PM EST
private void buttoTest_Click(object sender, EventArgs e)
{
try
{
MySqlConnection TestConnection = new MySqlConnection();
TestConnection.ConnectionString = "Data Source=localhost;Database= icepack;User ID=Demo;Password=Demo";
TestConnection.Open();
//
MySqlDataAdapter TestDataAdapter = new MySqlDataAdapter("SELECT * FROM Company", TestConnection);
DataSet TestDataSet = new DataSet();
//
TestDataAdapter.Fill(TestDataSet);
dataGridViewCompany.DataSource = TestDataSet.Tables[0];
//dataGridViewCompany.Bind(); // <<<< ERROR
MessageBox.Show("Got here...MySQL");
}
catch (SqlException SQLExecute)
{
MessageBox.Show("Can not connect to TestConnection...\r\r" + SQLExecute, "Test Connection...", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
theLizardRank #1,079 · 1.8K reputationPosted Mar 2, 2010, 1:30 PM EST
There is an enormous differences between the Sql.Data provider and the MySql Connector which is what you would need.
There are differences between MSSQL and MySql calling conventions, so why are you learning something that you know you are not going to use! I am completely baffled.
Finaly there is a website you can go to to get ALL you connection strings for ANY database or xl or txt or jet or ole or odbc connectionstrings.com try it .
GustavoRank #1,990 · 732 reputationPosted Mar 2, 2010, 2:27 PM EST
Here is the code I have so far:
private void buttoTest_Click(object sender, EventArgs e)
{
try
{
MySqlConnection TestConnection = new MySqlConnection();
TestConnection.ConnectionString = "Data Source=localhost;Database= icepack;User ID=Demo;Password=Demo";
TestConnection.Open();
//
MySqlDataAdapter TestDataAdapter = new MySqlDataAdapter("SELECT * FROM Company", TestConnection);
DataSet TestDataSet = new DataSet();
//
TestDataAdapter.Fill(TestDataSet);
dataGridViewCompany.DataSource = TestDataSet;
//dataGridViewCompany.Bind(); // <<<< ERROR
MessageBox.Show("Got here...MySQL");
}
catch (SqlException SQLExecute)
{
MessageBox.Show("Can not connect to TestConnection...\r\r" + SQLExecute, "Test Connection...", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
GustavoRank #1,990 · 732 reputationPosted Mar 2, 2010, 2:51 PM EST
Thanks for your help. I changed the line to what you recommended.
BUT: Should I put back in the "dataGridViewCompany.Bind();" so it populated the dataGridViewCompany?
It has an issue with the "Bind".
Kirtan PatelRank #292 · 8.6K reputationPosted Mar 2, 2010, 2:53 PM EST
its necessary in ASP.net but in windows application no need of it :)
The article you seen is for asp.net so they called Bind() method ..no need in Windows Application
GustavoRank #1,990 · 732 reputationPosted Mar 2, 2010, 3:00 PM EST
YES... It worked. I had to get rid of something that I put in the properties.
Now I can work on the MSSQL ConnectionString version. I used the MySQL because it was easier to connect to. I have to do some configurations to the MSSQL server so it will allow me access it.
theLizardRank #1,079 · 1.8K reputationPosted Mar 2, 2010, 3:58 PM EST