Chamuanza Posted April 1, 2012 at 09:55 AM Report #446853 Posted April 1, 2012 at 09:55 AM 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
jviana Posted April 1, 2012 at 10:41 AM Report #446856 Posted April 1, 2012 at 10:41 AM 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++
Chamuanza Posted April 1, 2012 at 11:00 AM Author Report #446860 Posted April 1, 2012 at 11:00 AM 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"
Chamuanza Posted April 1, 2012 at 01:41 PM Author Report #446875 Posted April 1, 2012 at 01:41 PM 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"
bruno1234 Posted April 1, 2012 at 02:12 PM Report #446876 Posted April 1, 2012 at 02:12 PM 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
bioshock Posted April 1, 2012 at 10:18 PM Report #446972 Posted April 1, 2012 at 10:18 PM http://www.w3schools.com/sql/sql_null_values.asp
poliveira1978 Posted April 2, 2012 at 02:48 PM Report #447083 Posted April 2, 2012 at 02:48 PM Também pode tentar: select * from [tabela] where [coluna] is not null
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