Skip navigation links

MySQL Forums :: Connector/NET and C#, Mono, .Net :: Using Wild card characters inside command statements


Advanced Search

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);
oMySqlConn.Open();
objRdr = objCmd.ExecuteReader();
myRepeater.DataSource = objRdr;
myRepeater.DataBind();
Thanks,

Options: ReplyQuote


Subject Written By Posted
Using Wild card characters inside command statements Ray ferns 05/17/2006 05:36AM
Re: Using Wild card characters inside command statements Peter Brawley 05/17/2006 07:26AM
Re: Using Wild card characters inside command statements Ray ferns 05/17/2006 09:44AM
Re: Using Wild card characters inside command statements Peter Brawley 05/17/2006 11:17AM


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.