Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to show information from mysql into a textbox (DescriptionTxtbx), however its not working correctly, sometimes displaying the wrong information depending what i click on ..

private void CarryOrderBtn_Click(object sender, EventArgs e)
{
SqlCommand Cmd = sqlcon.CreateCommand();
Cmd.CommandText = "select [Product Description] from CustomerOrders";
sqlcon.Open();
//fill in the textbox you want.
mainForm.DescriptionTxtbx.Text = Cmd.ExecuteScalar().ToString();
sqlcon.Close();

mainForm.ShowDialog();
}

What I have tried:

changing the code entirely, checking code
Posted
Updated 14-Dec-17 15:06pm

1 solution

Seems you are trying to connect MySQL using SQLClient provider which is actually suitable for connecting SQL Server.
For MySQL, try using MySQLClient.
C#
using MySql.Data.MySqlClient;

Here are some articles to guide you through detailed steps-
Connecting to MySQL Using C#.NET[^]
Connect C# to MySQL[^]

Hope, it helps :)

Please mark as solution if it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900