问题是无法获取所有值,只有第一条记录可用,即PMDES1_01
未捕获其他返回值,请帮助处理此代码
public class DataxAero
{
//Create new method to get data from xAero database
public static string GetData(string ORDNUM_10)
{
string PMDES1_01 = "";
string DESCRPTN_104 = "";
string PRTNUM_10 = "";
string ORDREF_10 = "";
string TNXDTE_01 = "";
//Create connection
SqlConnection con = new SqlConnection(@"Data Source=xxx;Initial Catalog=xxx;Integrated Security=true;");
//SQL Command
SqlCommand cmd = new SqlCommand("SELECT ...............", con);
//Open connection
con.Open();
//to read from SQL Server
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
PMDES1_01 = dr["PMDES1_01"].ToString();
PRTNUM_10 = dr["PRTNUM_10"].ToString();
DESCRPTN_104 = dr["DESCRPTN_104"].ToString();
ORDREF_10 = dr["ORDREF_10"].ToString();
TNXDTE_01 = dr["TNXDTE_01"].ToString();
}
//close connections
dr.Close();
con.Close();
//get the values
return PMDES1_01;
return PRTNUM_10; (get error here Unreachable code detected)
return DESCRPTN_104;
return ORDREF_10;
return TNXDTE_01;