FurqanAhmed
Programmer
Hi,
I'm working on a text box control on windows form. The text box helps the user in inputing hotel names. As the user inputs each letter of the hotel name,the text box provides the remaining name that matches the user provided input. For example, if the user input "HIL", the text box displays "HILTON".
Recently I've received couple of complain from users when they input this hotel name "4 * SELECT-RAD HOTEL". The specific error that is given is "Error in Like operator: the string pattern '4 * %' is invalid.". What I've figured out so far is whenever the '%' operation is used after '*', an error is generated. The C# code is
----------------------------------
DataView dv;
dv = new DataView(this.hotelTable, "Name LIKE '"+txtHotelName.Text+"%'", "Name", DataViewRowState.CurrentRows);
if(dv.Count > 0)
{
int txtCount = txtHotelName.Text.Length;
string hotelName = dv[0]["Name"].ToString();
this.lsbErrors.Items.Add(""+dv[0]["ID"].ToString());
this.acceptChanges = false;
txtHotelName.Text = hotelName;
txtHotelName.SelectionStart = txtCount;
txtHotelName.SelectionLength = hotelName.Length - txtCount;
this.acceptChanges = true;
}
------------------------------------------------------
this is the method body for the TextChanges Event.
Can anyone tell me how to solve this problem?
I'm working on a text box control on windows form. The text box helps the user in inputing hotel names. As the user inputs each letter of the hotel name,the text box provides the remaining name that matches the user provided input. For example, if the user input "HIL", the text box displays "HILTON".
Recently I've received couple of complain from users when they input this hotel name "4 * SELECT-RAD HOTEL". The specific error that is given is "Error in Like operator: the string pattern '4 * %' is invalid.". What I've figured out so far is whenever the '%' operation is used after '*', an error is generated. The C# code is
----------------------------------
DataView dv;
dv = new DataView(this.hotelTable, "Name LIKE '"+txtHotelName.Text+"%'", "Name", DataViewRowState.CurrentRows);
if(dv.Count > 0)
{
int txtCount = txtHotelName.Text.Length;
string hotelName = dv[0]["Name"].ToString();
this.lsbErrors.Items.Add(""+dv[0]["ID"].ToString());
this.acceptChanges = false;
txtHotelName.Text = hotelName;
txtHotelName.SelectionStart = txtCount;
txtHotelName.SelectionLength = hotelName.Length - txtCount;
this.acceptChanges = true;
}
------------------------------------------------------
this is the method body for the TextChanges Event.
Can anyone tell me how to solve this problem?