c# - 使用c#从mysql返回两个值

标签 c# mysql

请告诉我,为什么当我使用这部分代码时,我只能返回 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();
....
}

关于c# - 使用c#从mysql返回两个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22944887/

相关文章:

mysql - 覆盖 MySQL 表中的数据

php - 如何将博客从非 WordPress 迁移到 WordPress

c# - 通用函数错误

c# - 如何在 Xamarin.Forms.Maps 中使用暗模式谷歌地图?

c# - 从 XmlWriter 中删除编码

c# - 跟踪 Entity Framework 中与行为的多对多关系的变化

mysql查询选择多对多

MySQL可以通过命令行连接远程,但Laravel失败

小于 3 且放置不止一次的 MySQL 子查询

c# - 如何将参数传递给 TypeConverter 派生类