Chamuanza Posted April 1, 2012 Report Share Posted April 1, 2012 Um Bem Aja a Todos Estou com dificuldade em fazer um select a fim de obter todos os registos com email numa tabela em que a referida coluna tem muitos registos com "Null" Private Sub Encontro2012PorEmailToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Encontro2012PorEmailToolStripMenuItem.Click Dim ConnectionString As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & My.Application.Info.DirectoryPath & "\ChamuanzasNet.mdb") Dim query As String = "SELECT * FROM ListaChamuanzasTotal WHERE Email = @Email Order By Id" Dim command As New OleDbCommand(query, ConnectionString) ' Seleccionar os dados APENAS dos que têm Email command.Parameters.Add("@Email", OleDbType.VarChar).Value = "Null" Dim DataAdapter As New OleDbDataAdapter(command) Dim MyData As New DataSet DataAdapter.Fill(MyData, "ListaChamuanzasTotal") Me.DataGridView1.DataSource = MyData.Tables("ListaChamuanzasTotal") ' Neste caso utilizei uma datagridview para visualizar os dados Call FormatarTabela() Me.Text = "Lista para Encontro de CHAMUANZAS com Email 2012" ReporListaGeralToolStripMenuItem.Enabled = True End Sub Quando coloco = "Null" obtenho todos os registos com Null Quando coloco <> "Null" apresenta esta mensagem "Property access must assign to the property or use its value" O campo na BD está defenido como texto Obrigado desde já pela atenção Link to comment Share on other sites More sharing options...
jviana Posted April 1, 2012 Report Share Posted April 1, 2012 Não estou a perceber onde queres por o Null, e para que é que queres por o Null Cumps. J.Viana Learning VB.Net HTML C/C++ Link to comment Share on other sites More sharing options...
Chamuanza Posted April 1, 2012 Author Report Share Posted April 1, 2012 o que pretendo é obter todos os registos que tem o endereço de email, estando alguns registos com Null (texto) terei que colocar no select <> "Null" Mas quando faço command.Parameters.Add("@Email", OleDbType.VarChar).Value <> "Null" apresenta esta mensagem "Property access must assign to the property or use its value" Link to comment Share on other sites More sharing options...
Chamuanza Posted April 1, 2012 Author Report Share Posted April 1, 2012 o que pretendo é obter todos os registos que tem o endereço de email, estando alguns registos com Null (texto) terei que colocar no select <> "Null" Mas quando faço Código (vb.net): [seleccione] command.Parameters.Add("@Email", OleDbType.VarChar).Value <> "Null" apresenta esta mensagem "Property access must assign to the property or use its value" Link to comment Share on other sites More sharing options...
bruno1234 Posted April 1, 2012 Report Share Posted April 1, 2012 Experimenta usar o DBNull.Value: http://msdn.microsoft.com/en-us/library/system.dbnull.value.aspx#Y0 Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
bioshock Posted April 1, 2012 Report Share Posted April 1, 2012 http://www.w3schools.com/sql/sql_null_values.asp Link to comment Share on other sites More sharing options...
poliveira1978 Posted April 2, 2012 Report Share Posted April 2, 2012 Também pode tentar: select * from [tabela] where [coluna] is not null Link to comment Share on other sites More sharing options...
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