使用c#从mysql返回两个值
本文关键字:两个 mysql 返回 使用 | 更新日期: 2023-09-27 17:57:38
请告诉我为什么当我使用这部分代码时,我只能返回Select查询的结果,而不能返回Select2?请
con.ConnectionString = mysqlSB.ConnectionString;
MySqlCommand Select = new MySqlCommand("select id from table1 where lang ='ua'", con);
MySqlCommand Select2 = new MySqlCommand("select id from table2 where car='bmw'", con);
MySqlDataReader myReader;
MySqlDataReader myReader2 ;
con.Open();
myReader = Select.ExecuteReader();
myReader2 = Select2.ExecuteReader();
return (myReader2["id"].ToString());
您可以使用两个'out'参数,将它们传递给函数并用结果填充。
public void MyFunction(out string res1, out string res2){
....
res1 = select.toString();
....
}