Home All Groups Group Topic Archive Search About

Problem with parameter

Author
10 Sep 2006 4:54 PM
reidarT
I still have a probem with a parameter.
Here is my code.
Dim Bruker As String = Me.AnsattNavn.Text

Dim Utfort As Boolean = (True Or False)

'Innboks

dgvInnboks.DataSource = InnboksPrBrukerBindingSource

Me.InnboksPrBrukerTableAdapter.Fill(Me.MeldingDBsqlDataSet.InnboksPrBruker,
Bruker, Utfort)

dgvInnboks.Refresh()

The problem is that Utfort is returning just one of the two possibilities.
Either true or false, not both of them

My tableadapter sql is

SELECT     ToDoID, Dato, Bruker, Melding, MeldingFra, Utfort
FROM         tblToDo
WHERE     (Bruker = @Bruker) AND (Utfort = @Utfort)
ORDER BY ToDoID DESC

When Utfort = true it works, when Utfort = false it works

When Utfort = True OR False it does not work.

How can I omit the last situation.

The field Utfort is set as a bit in the table (sql db)

reidarT

Author
10 Sep 2006 6:29 PM
Kerry Moorman
reidarT,

(True Or False) will always evaluate to True.

You can't specify 2 values in a Where clause using  the "=" operator.
(Utfort = @Utfort) can only accept 1 value. @Utfort can be True or @Utfort
can be False.

You will need to change your SQL Select statement if you want this much
flexibility in specifying values for Utfort.

Kerry Moorman


Show quoteHide quote
"reidarT" wrote:

> I still have a probem with a parameter.
> Here is my code.
> Dim Bruker As String = Me.AnsattNavn.Text
>
> Dim Utfort As Boolean = (True Or False)
>
> 'Innboks
>
> dgvInnboks.DataSource = InnboksPrBrukerBindingSource
>
> Me.InnboksPrBrukerTableAdapter.Fill(Me.MeldingDBsqlDataSet.InnboksPrBruker,
> Bruker, Utfort)
>
> dgvInnboks.Refresh()
>
> The problem is that Utfort is returning just one of the two possibilities.
> Either true or false, not both of them
>
> My tableadapter sql is
>
> SELECT     ToDoID, Dato, Bruker, Melding, MeldingFra, Utfort
> FROM         tblToDo
> WHERE     (Bruker = @Bruker) AND (Utfort = @Utfort)
> ORDER BY ToDoID DESC
>
> When Utfort = true it works, when Utfort = false it works
>
> When Utfort = True OR False it does not work.
>
> How can I omit the last situation.
>
> The field Utfort is set as a bit in the table (sql db)
>
> reidarT
>
>
>
>
>
>
>
>
>