如何使用 c# 添加递归函数以从 Mysql 获取列

How to add a recursive function to obtain columns from Mysql using c#

for (int count = 1; count < 5; count++) {
    String myConnection = "datasource=localhost;port=3306;username=root;password=2015";
    MySqlConnection myconn = new MySqlConnection(myConnection);

    MySqlCommand cmdDataBase1 = new MySqlCommand("select Question FROM quizdb.qans where slno=count;", myconn);

    try {
        MySqlDataAdapter sda = new MySqlDataAdapter();

        sda.SelectCommand = cmdDataBase1;

        DataTable dbdataset = new DataTable();

        sda.Fill(dbdataset);

        BindingSource bSource = new BindingSource();
        bSource.DataSource = dbdataset;

        dataGridView1.DataSource = bSource;
        dataGridView2.DataSource = bSource;
        dataGridView3.DataSource = bSource;
        dataGridView4.DataSource = bSource;
    } catch (Exception Exception) {
        MessageBox.Show(Exception.Message);
    }

}

字符串 myConnection = "datasource=localhost;port=3306;username=root;password=2015"; MySqlConnection myconn = new MySqlConnection(myConnection); 随机 rnd = new Random(); var temp = rnd.Next(1, 4); DataColumn myCol = new DataColumn();

        myconn.Open();
        MySqlCommand cmdDataBase1 = new MySqlCommand("select * FROM quizdb.aeasy order by rand();", myconn);

        try
        {

            MySqlDataAdapter sda = new MySqlDataAdapter();

            sda.SelectCommand = cmdDataBase1;

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.Tables.Add(dt);

            sda.Fill(dt);


            foreach (DataRow myRow in dt.Rows)
            {

                label1.Text = myRow[1].ToString();
                radioButton1.Text = myRow[2].ToString();
                radioButton2.Text = myRow[3].ToString();
                radioButton3.Text = myRow[4].ToString();
                radioButton4.Text = myRow[5].ToString();

                //label1.Text = myRow[6].ToString();

            }






        }



        catch (Exception Exception)
        {
            MessageBox.Show(Exception.Message);
        }
        myconn.Close();

    }