-3

In MySql table have data and also have some empty values in the same row. Now I want to display that data into the user without that empty values. I'm not write any code yet

3
  • 2
    Welcome to Stack Overflow. Please take the tour to learn how Stack Overflow works and read How to Ask on how to improve the quality of your question. Please show your attempts you have tried and the problems/error messages you get from your attempts. Commented Jul 9, 2022 at 10:36
  • 1
    It is not acceptable for you to come here and post "I want to do X, please write the code for me". That's not what this site is for. If you don't know how to write code, learn. There are lots of tutorials out there. Think about the logic involved in performing the desired task - how would you do it if you had to do it manually - and then write code to implement that logic. If you run into a specific issue when writing the code to implement the logic that you already worked out, then you have a question to ask here. Commented Jul 9, 2022 at 10:53
  • How do I format my post? Commented Nov 16, 2022 at 8:08

1 Answer 1

1

Welcome to Stack Overflow!

1. I'm not too familiar with C# winforms, but this post can help you establish a connection to your MySQL database where you can query for specific data.

Code taken from that post:

string myConnectionString = "server=localhost;database=testDB;uid=root;pwd=abc123;";
private void button1_Click(object sender, EventArgs e)
{
    MySqlConnection cnn = new MySqlConnection(myConnectionString);
    try
    {
        cnn.Open();
        MessageBox.Show ("Connection Open!");
        cnn.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show("Cannot open connection!");
    }
}

Data is retrieved from a MySQL database using a specific SQL (or "Structured Query Language"). In order to learn the basic MySQL syntax for queries, I would recommend a turorial like this.

3. To send a SQL query to your database (via your established connection in Step 1) I would recommend looking at this post that gives an example on how to send a query via C# winforms

Code taken from that post:

  public void Select(string filename)
    {
        string query = "SELECT * FROM banners WHERE file = '"+filename+"'";

        //open connection
        if (this.OpenConnection() == true)
        {
            //create command and assign the query and connection from the constructor
            MySqlCommand cmd = new MySqlCommand(query, connection);

            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            this.CloseConnection();
        }
    }

Overall, you're missing a few steps inbetween C# winforms and MySQL. Different languages USUALLY have an external library that facilitates: establishing a MySQL connection and launching MySQL queries. After obtaining the data from a MySQL query return, its up to you on how to display it to the user!

Hope this helps :D

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.