is the query returning you the value in SQL query analyzer ?? if yes then plz check ur code.U might b missing something.
Pls chk the following sample code
string strConnection = "Server=;Database=Testing;user ID=;password=; ";
SqlConnection sqlConn = new SqlConnection(strConnection);
string strQuery = "UR QUERY ";
sqlConn.Open();
SqlCommand sqlComm = new SqlCommand(strQuery,sqlConn);
SqlDataAdapter sqa= new SqlDataAdapter(sqlComm);
DataSet ds=new DataSet();
sqa.Fill(ds);