Does some one know, how to use wildcards with ado.net parameter in sybase sql anywhere?
For example i want to search for all names, starting with Se
. In a normal query i would use select * from names where name like 'Se%'
. But in ADO.Net my query looks like SELECT * from names where name like ?
and the question mark will be set over SAParameter
.
SACommand command = new SACommand(SqlStatement, cConnection);
command.Parameters.Add(new SAParameter() { Value = "Se%" });
The problem is, Value
could not contains any wildcards.
Thank you very much!
here's my solution example
using (SAConnection con = new SAConnection(DBConnStr))
{
con.Open();
try
{
string sql = "select * from names where name like ?";
SACommand cmd = new SACommand(sql, con);
cmd.Parameters.Add("@p1","Se%");
SADataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr["name"].ToString());
}
rdr.Close();
}
finally
{
con.Close();
}
}
Console.ReadLine();