srjohny Posted February 17, 2009 at 01:47 PM Report #245089 Posted February 17, 2009 at 01:47 PM boas. eu tenho este webservice [WebMethod(Description = "Ligação Sql - Listar por numero por cliente")] public DataSet listone(string Numero) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=.\SQLexpress;AttachDbFilename=C:\Trabalho isi\data\Clientes.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; conn.Open(); string query = @"select * from clientes where (Numero = @Numero)"; SqlDataAdapter da = new SqlDataAdapter(query, conn); DataSet ds = new DataSet(); da.SelectCommand.Parameters.Add("@Numero", SqlDbType.VarChar).Value = Numero; da.Fill(ds, "cliente"); conn.Close(); { } return ds; } isto dá-me a linha completa do numero utilizador que peço. mas eu gostaria era que só me retornasse o numero. caso ele exista como posso fazeR?
Hellblazer Posted February 17, 2009 at 02:22 PM Report #245104 Posted February 17, 2009 at 02:22 PM Primeiro podias usar ai uma datatable que é mais leve. Depois se so queres o numero tens de alterar a query de "select * from clientes where (Numero = @Numero)" para "select Numero from clientes where (Numero = @Numero)" Espero ter entendido :S There are two ways to write error-free programs; only the third one works.
srjohny Posted February 17, 2009 at 10:40 PM Author Report #245242 Posted February 17, 2009 at 10:40 PM obrigado, datatable nao sei fazer, mas vou pesquisar.
Hellblazer Posted February 18, 2009 at 09:22 AM Report #245279 Posted February 18, 2009 at 09:22 AM obrigado, datatable nao sei fazer, mas vou pesquisar. Basicamente um Dataset e constituido por varios DataTables ou seja, nesse caso como so estas a utilizar uma Tabela do DataSet seria melhor para a aplicação utilizares apenas um DataTable 😞 There are two ways to write error-free programs; only the third one works.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now