我正試圖從sql查詢中返回2個值的連接。我搜索NOM和prenom數據庫,並希望他們能回來作爲SQL ExecuteScalar 2返回值?
prenom+" "+nom
然而,當我執行以下的,可我現在的returnValue得到的是
nom
代碼:
SqlConnection MyConnection = new SqlConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["SearchConnectionString"].ConnectionString;
SqlCommand searchCommand = new SqlCommand();
searchCommand.CommandText = "select nom,prenom from [reference].[dbo].[v_employe] where compagnie like @compagnie and no_employe like @num";
searchCommand.CommandType = CommandType.Text;
searchCommand.Connection = MyConnection;
SqlParameter p1 = new SqlParameter("@compagnie", this.REComboboxSearch.Value);
SqlParameter p2 = new SqlParameter("@num", this.RESearchId.Value);
searchCommand.Parameters.Add(p1);
searchCommand.Parameters.Add(p2);
MyConnection.Open();
returnValue = (String)searchCommand.ExecuteScalar();
MyConnection.Close();
謝謝!
你在哪裏試圖連接它們?我只看到'select nom,prenom from' – 2014-09-18 17:49:05
從模式和標識符的轉義我寧願認爲它是sql服務器而不是MySQL。 – VMai 2014-09-18 17:53:37