用c#从mysql返回两个值

时间:2014-04-08 18:06:56

标签: 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());

1 个答案:

答案 0 :(得分:0)

你可以使用两个' out'传递给函数的参数,并将其填入结果。

public void MyFunction(out string res1, out string res2){
....
res1 = select.toString();
....
}