Question Locked

Can we use Array Variable to save query in VB.net?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I put a query in a function, and I need new query when the function is called.

2 replies

by tony hopkinson

I can think of several things you could be asking.

Don't know which one you mean though.

If you are talking about building a query from an array, (e.g a number of columns to select), or a number of values for a where clause, remember these.

There could be none or one or effectively unlimited.

The order of the items..

If your query is
Where A = Value[0] or A = Value[1]

no problem.

if it were
Where A = Value[0] or B = Value[1]

It's isn't an array. For that sort of thing you'd be better off with a Dictionary. Go too far down that route though and you've just reinvented SQL.

Personally I'd write a function for each query unless there was some major design consideration not to. Give them nice names. Easier to read , change and debug.

I six months time when you have to revisit this code. Do you want to see

DoQuery(["Fred", "Wilma"])

Or

GetChildren(Husband, Wife)

This discussion is closed to new replies.