From This question, its answer is almost my answer. But I am facing some sql query issue, I have the following statement in VB
Dim results As DataRow() = table.Select("A = 'foo' AND B = 'bar' AND C = 'baz'")
I want to place foo, bar and baz
in variables and use that variables in above statements.
Dim Varfoo As String = "foo"
Dim Varbar As String = "bar"
Dim Varbaz As String = "baz"
I managed to get one variable in statement as
Dim results As DataRow() = table.Select("A = " + Varfoo)
But how to insert multiple sort expressions with variables?
Edit: I got it solved with the answer of vikas as following;
Dim results As DataRow() = table.Select("A = '" & Varfoo & "' And B = '" & Varbar & "' And C = '" & Varbaz & "'")
Have you tried
Dim results As DataRow() = table.Select("A = '" & Varfoo & "'")
Edited
For OR operation
Dim results As DataRow() = table.Select("A = '" & Varfoo & "' OR B = '" & Varbar & "' OR C = '" & Varbaz & "'")
For AND operation
Dim results As DataRow() = table.Select("A = '" & Varfoo & "' AND B = '" & Varbar & "' AND C = '" & Varbaz & "'")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With