+1 vote
15 views

Hello guyz! I am working on a c# project and using MySql as database server. I have much knowledge of MySql database but I don't know how to get query results in c#. Even I don't know how to connect to MySql server via c#. Anybody here who can help me?
Thanks! Keyworkds:
how to query and get results from mysql with c#
How to ue MySql select with c#
MySql query in c#

by (1.4k points)   | 15 views

1 Answer

0 votes

Try this code:


var Con = new MySqlConnection("ConString");
try
                {
                    Con.Open();
                    MySqlCommand cmd = new MySqlCommand(SQL, Con);

                DataTable dt = new DataTable();
                var rd = cmd.ExecuteReader();

                //Use rd in your dataGridView or anywhere you want

                }
                catch(Exeption e)
                {
                    MessageBox.Show(e.ToString());
                }
by (3.3k points)  

Related questions

+1 vote
1 answer
asked May 27 by toheed (1.4k points) | 23 views
+1 vote
1 answer
asked May 27 by toheed (1.4k points) | 14 views
+2 votes
1 answer
asked Jun 5 by toheed (1.4k points) | 17 views
0 votes
1 answer
+1 vote
2 answers
+2 votes
3 answers
+1 vote
1 answer
+3 votes
1 answer
+3 votes
1 answer




Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
118 questions
90 answers
43 comments
111 users