views:

62

answers:

2

Hey guys,

i was wondering, can a parameter be used more then once in the same query, like this :

MySqlParameter oPar0 = new MySqlParameter("e164", MySqlDbType.String);
oPar0.Value = user.E164;
string sSQL0 = "Delete from callmone.call where (caller=?e164 or called=?e164);";
clsDatabase.ExecuteSQL(sSQL0, oPar0);

Is this possible or should i write 2 parameters?

+2  A: 

I don't know of any reason why you can't do that.

ChrisF
+3  A: 

If the database driver handles named parameters, then you can reuse the parameter.

If the database driver doesn't handle named parameters, the parameter names are ignored and you have to add one parameter values for each use, in the exact order that they are used.

From the code that you presented it looks like the driver supports named parameters. If the code runs without an error, it works. If the driver would not support names parameters, the code would cause an error as there is only one parameter value.

Guffa
Wrikken