MilkBottle
MilkBottle

Reputation: 4332

How to express the Parameters correctly in SQLite Select statement

I am just not sure the correct way to express the parameters in the SQLite Select statement with parameters.

In the Select-statement , how to express?

1) use =? or ='?'

"Is_Offline_Trans =?" or "Is_Offline-Trans='?'"

2) for Number, Example "0" or "'0'"

3) For String

Example: "SQlite's Rocking solid" or "'SQLite's Rocking Solid"


is this correct?

here my Parameterized Select statement:
string string Company ="Anderson's Studio";


var Orders = db.Query<SalesOrderHeader >("Select * From SalesOrderHeader Where Is_SyncToNAV =?" + 
" AND Is_Offline_Trans =?" +
" AND DataEntryComplete =?" + 
" AND Company =?","0" ,"1" ,"1", Company);


Can I do hard code for the company this way:

" AND Company =?", "Anderson's Studio"

Your help is greatly appreciated.

Thanks

Upvotes: 1

Views: 134

Answers (1)

CL.
CL.

Reputation: 180060

Inside the SQL statement, a parameter is just a single ?. With quotes, '?' would be a string containing a single question mark character.

The parameter values are not given in SQL. but come from your program. Therefore, you must write them correctly for the programming language that you're using. (C# does not quote numbers.)

Upvotes: 1

Related Questions