gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 22:55:06 26 4
gpt4 key购买 nike

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);
}

}

最佳答案

String myConnection = "数据源=localhost;端口=3306;用户名=root;密码=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();

}

关于c# - 如何使用c#添加递归函数从Mysql获取列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28745045/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com