Using Wild card characters inside command statements
Posted by: Ray ferns
Date: May 17, 2006 05:36AM

Hi there,

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("?RoomNo", txtRoomNo.Text.Trim());
objCmd.Parameters.Add("?RoomType", txtRoomType.Text.Trim());
objCmd.Parameters.Add("?Capacity", MySqlDbType.Int32, 3).Value = txtCapacity.Text.Trim();
objCmd.Parameters.Add("?RescName", lstResources.SelectedItem.Value);
objRdr = objCmd.ExecuteReader();
myRepeater.DataSource = objRdr;

Options: ReplyQuote

Written By
Using Wild card characters inside command statements
May 17, 2006 05:36AM

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.