SQL 쿼리에서 2 개의 값의 연결을 반환하려고합니다. 나는 NOM과 prenom에 대한 데이터베이스를 검색하고 난 다음을 실행할 때, 내가 ReturnValue를 얻을 모두가,SQL ExecuteScalar 2 반환 값?
그러나prenom+" "+nom
로를 반환하고 싶은
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'을 보았습니다. –
스키마와 식별자의 도주에서 나는 오히려 그것이 MySQL이 아니라 SQL 서버라고 생각합니다. – VMai