Using Wild card characters inside command statements
Date: May 17, 2006 05:36AM
I am trying to create a SQL query based on users input of three fields.
RoomNo (Optional field), Capacity (mandatory) and Room type(mandatory).
I want to use LIKE clause in the where statement to return matching records of RoomNo and RoomType. How can I achieve this using this statement
objCmd = new MySqlCommand("select * from Rooms WHERE Capacity >= ?Capacity AND RoomType like ?RoomType% OR RoomNo like ?RoomNo group by RoomNo order by capacity desc",oMySqlConn );
objCmd.Parameters.Add("?Capacity", MySqlDbType.Int32, 3).Value = txtCapacity.Text.Trim();
objRdr = objCmd.ExecuteReader();
myRepeater.DataSource = objRdr;
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.