public static bool isEmail(string inputEmail)
{
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
Thursday, December 16, 2010
Thursday, December 9, 2010
Monday, December 6, 2010
connectionstring
strcnn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\myDbase.mdb;uid=admin;pwd=;"
http://en.allexperts.com/q/Visual-Basic-1048/VB-MS-Access-connection-1.htm
http://www.connectionstrings.com/access-2007
http://en.allexperts.com/q/Visual-Basic-1048/VB-MS-Access-connection-1.htm
http://www.connectionstrings.com/access-2007
Sunday, December 5, 2010
get the expire date
declare @DesiredDateAtMidnight datetime = '20010709'declare @NextDateAtMidnight datetime = dateadd(day,1,@DesiredDateAtMidnight)select OrderID=h.SalesOrderID ,h.OrderDate ,h.TerritoryID ,TerritoryName=t.Name ,c.CardType ,c.CardNumber ,CardExpire=right(str(100+ExpMonth),2)+'/'+str(ExpYear,4) ,h.TotalDuefrom Sales.SalesOrderHeader hleft join Sales.SalesTerritory t on h.TerritoryID=t.TerritoryID left join Sales.CreditCard c on h.CreditCardID=c.CreditCardID where OrderDate>=@DesiredDateAtMidnight and OrderDate<@NextDateAtMidnight order by h.SalesOrderID
chk title
Int32 andindex = -1;
Int32 orindex = -1;
Int32 notindex = -1;
Int32 innerANDindex = -1;
Int32 innerORindex = -1;
Int32 innerNOTindex = -1;
if (txt.Text.Contains("AND"))
{
andindex = txt.Text.IndexOf("AND");
}
if (txt.Text.Contains("OR"))
{
orindex = txt.Text.IndexOf("OR");
}
if (txt.Text.Contains("NOT"))
{
notindex = txt.Text.IndexOf("NOT");
}
bool CHK5 = txt.Text.Contains("OR");
bool CHK6 = txt.Text.Contains("NOT");
bool CHK7 = txt.Text.Contains("AND");
if (CHK5 == false && CHK6 == false && CHK7 == false)
{
qry = "Select * from table where field Like '%" + txt.Text + "%' OR field1 Like '%" + txt.Text + "%'";
Response.Write(qry);
}
if (andindex > -1 & orindex > -1 & notindex > -1)
{
if (andindex < orindex & andindex < notindex)
{
if (orindex < notindex)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, notindex - innerORindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, orindex - innerANDindex) + "%' OR field1 LIKE '%" + txt.Text.Substring(innerORindex, notindex - innerORindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%'";
Response.Write(qry);
}
else
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, notindex - innerANDindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, notindex - innerANDindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%' OR field1 LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%'";
Response.Write(qry);
}
}
else
{
if (orindex < andindex & orindex < notindex)
{
if (andindex < notindex)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, notindex - innerANDindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, andindex - innerORindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, notindex - innerANDindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%'";
Response.Write(qry);
}
else
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, notindex - innerORindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, andindex - innerNOTindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, notindex - innerORindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, andindex - innerNOTindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
Response.Write(qry);
}
}
else
{
if (notindex < andindex & notindex < orindex)
{
if (andindex < orindex)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, andindex - innerNOTindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(0, andindex - innerNOTindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%'OR field1 LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%'";
Response.Write(qry);
}
else
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%'OR field1 LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
Response.Write(qry);
}
}
}
}
}
else
{
//--------AND CONDITION------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
bool CHK1 = txt.Text.Contains("OR");
bool CHK2 = txt.Text.Contains("NOT");
if (CHK1 == false && CHK2==false)
{
if (andindex > -1)
{
innerANDindex = andindex + 3;
string aa = txt.Text.Substring(innerANDindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + aa + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + aa + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field1 LIKE '%" + aa + "%'";
Response.Write(qry);
}
}
if (CHK2 == false)
{
if (andindex < orindex)
{
if (andindex > -1 && orindex > -1)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
string aa = txt.Text.Substring(innerANDindex);
string BB = txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field LIKE '%" + BB + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field LIKE '%" + BB + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field1 LIKE '%" + BB + "%'";
Response.Write(qry);
}
}
}
if (andindex < notindex)
{
if (andindex > -1 && notindex > -1)
{
innerANDindex = andindex + 3;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, andindex - 1);
string BBA = txt.Text.Substring(innerANDindex, innerNOTindex - innerANDindex - 3);
string bbc = txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field1 LIKE '%" + BBA + "%' AND field1 NOT LIKE '%" + bbc + "%'";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
//--------OR CONDITION------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
if (orindex == 0)
{
}
else
{
bool chkh = txt.Text.Contains("AND");
bool chkh2 = txt.Text.Contains("NOT");
if (chkh == false && chkh2==false)
{
if (orindex > -1)
{
innerORindex = orindex + 2;
string aa = txt.Text.Substring(innerORindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + aa + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + aa + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field1 LIKE '%" + aa + "%'";
Response.Write(qry);
}
}
if (orindex < andindex)
{
//if (orindex > -1 && orindex < -1)
//{
//}
if (andindex > -1 & orindex > -1)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
string aa = txt.Text.Substring(0, orindex - 1);
string BB = txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%' OR field1 LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
Response.Write(qry);
notindex = 0;
}
}
}
if (orindex < notindex)
{
if (orindex > -1 && notindex > -1)
{
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, orindex - 1);
string BBA = txt.Text.Substring(innerORindex, innerNOTindex - innerORindex - 3);
string bbc = txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex);
//qry = "Select * from table where field Like '%" + aaA + "%'OR field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + aaA + "%'OR field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%' OR field1 Like '%" + aaA + "%'OR field1 LIKE '%" + BBA + "%' AND field1 NOT LIKE '%" + bbc + "%' ";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
//--------NOT CONDITION------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
bool chkh1 = txt.Text.Contains("AND");
bool chkhh = txt.Text.Contains("OR");
if (notindex == 0)
{
}
if (chkh1 == false && chkhh==false)
{
if (notindex > -1)
{
innerNOTindex = notindex + 3;
string aa = txt.Text.Substring(innerNOTindex);
// qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + aa + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + aa + "%' OR field1 Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field1 NOT LIKE '%" + aa + "%'";
Response.Write(qry);
}
}
if (chkhh == false)
{
if (notindex < andindex)
{
if (notindex != 0)
{
if (notindex > -1 && andindex > -1)
{
innerANDindex = andindex + 3;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, notindex - 1);
string BBA = txt.Text.Substring(innerNOTindex, innerANDindex - innerNOTindex - 3);
string bbc = txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex);
//qry = "Select * from table where field Like '%" + aaA + "%'AND field NOT LIKE '%" + BBA + "%' AND field LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + aaA + "%'AND field NOT LIKE '%" + BBA + "%' AND field LIKE '%" + bbc + "%' OR field1 Like '%" + aaA + "%'AND field1 NOT LIKE '%" + BBA + "%' AND field1 LIKE '%" + bbc + "%'";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
}
}
if (chkh1 == false)
{
if (notindex < orindex)
{
if (orindex > -1 && notindex > -1)
{
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, notindex - 1);
string BBA = txt.Text.Substring(innerNOTindex, orindex - innerNOTindex);
string bbc = txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex);
//qry = "Select * from table where field Like '%" + aaA + "%' AND field NOT LIKE '%" + BBA + "%' OR field LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + aaA + "%' AND field NOT LIKE '%" + BBA + "%' OR field LIKE '%" + bbc + "%' OR field1 Like '%" + aaA + "%' AND field1 NOT LIKE '%" + BBA + "%' OR field1 LIKE '%" + bbc + "%' ";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
}
}
}
Int32 orindex = -1;
Int32 notindex = -1;
Int32 innerANDindex = -1;
Int32 innerORindex = -1;
Int32 innerNOTindex = -1;
if (txt.Text.Contains("AND"))
{
andindex = txt.Text.IndexOf("AND");
}
if (txt.Text.Contains("OR"))
{
orindex = txt.Text.IndexOf("OR");
}
if (txt.Text.Contains("NOT"))
{
notindex = txt.Text.IndexOf("NOT");
}
bool CHK5 = txt.Text.Contains("OR");
bool CHK6 = txt.Text.Contains("NOT");
bool CHK7 = txt.Text.Contains("AND");
if (CHK5 == false && CHK6 == false && CHK7 == false)
{
qry = "Select * from table where field Like '%" + txt.Text + "%' OR field1 Like '%" + txt.Text + "%'";
Response.Write(qry);
}
if (andindex > -1 & orindex > -1 & notindex > -1)
{
if (andindex < orindex & andindex < notindex)
{
if (orindex < notindex)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, notindex - innerORindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, orindex - innerANDindex) + "%' OR field1 LIKE '%" + txt.Text.Substring(innerORindex, notindex - innerORindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%'";
Response.Write(qry);
}
else
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, notindex - innerANDindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, notindex - innerANDindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%' OR field1 LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%'";
Response.Write(qry);
}
}
else
{
if (orindex < andindex & orindex < notindex)
{
if (andindex < notindex)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, notindex - innerANDindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, andindex - innerORindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, notindex - innerANDindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex) + "%'";
Response.Write(qry);
}
else
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, notindex - innerORindex) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, andindex - innerNOTindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field1 LIKE '%" + txt.Text.Substring(0, notindex - innerORindex) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, andindex - innerNOTindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
Response.Write(qry);
}
}
else
{
if (notindex < andindex & notindex < orindex)
{
if (andindex < orindex)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, andindex - innerNOTindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(0, andindex - innerNOTindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%'OR field1 LIKE '%" + txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex) + "%'";
Response.Write(qry);
}
else
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%'OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field1 NOT LIKE '%" + txt.Text.Substring(innerNOTindex, orindex - innerNOTindex) + "%'OR field1 LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
Response.Write(qry);
}
}
}
}
}
else
{
//--------AND CONDITION------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
bool CHK1 = txt.Text.Contains("OR");
bool CHK2 = txt.Text.Contains("NOT");
if (CHK1 == false && CHK2==false)
{
if (andindex > -1)
{
innerANDindex = andindex + 3;
string aa = txt.Text.Substring(innerANDindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + aa + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + aa + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field1 LIKE '%" + aa + "%'";
Response.Write(qry);
}
}
if (CHK2 == false)
{
if (andindex < orindex)
{
if (andindex > -1 && orindex > -1)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
string aa = txt.Text.Substring(innerANDindex);
string BB = txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field LIKE '%" + BB + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field LIKE '%" + BB + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, orindex - innerANDindex) + "%' OR field1 LIKE '%" + BB + "%'";
Response.Write(qry);
}
}
}
if (andindex < notindex)
{
if (andindex > -1 && notindex > -1)
{
innerANDindex = andindex + 3;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, andindex - 1);
string BBA = txt.Text.Substring(innerANDindex, innerNOTindex - innerANDindex - 3);
string bbc = txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%' OR field1 Like '%" + txt.Text.Substring(0, andindex - 1) + "%'AND field1 LIKE '%" + BBA + "%' AND field1 NOT LIKE '%" + bbc + "%'";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
//--------OR CONDITION------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
if (orindex == 0)
{
}
else
{
bool chkh = txt.Text.Contains("AND");
bool chkh2 = txt.Text.Contains("NOT");
if (chkh == false && chkh2==false)
{
if (orindex > -1)
{
innerORindex = orindex + 2;
string aa = txt.Text.Substring(innerORindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + aa + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field LIKE '%" + aa + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%'OR field1 LIKE '%" + aa + "%'";
Response.Write(qry);
}
}
if (orindex < andindex)
{
//if (orindex > -1 && orindex < -1)
//{
//}
if (andindex > -1 & orindex > -1)
{
innerANDindex = andindex + 3;
innerORindex = orindex + 2;
string aa = txt.Text.Substring(0, orindex - 1);
string BB = txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex);
//qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, orindex - 1) + "%' OR field LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%' OR field1 Like '%" + txt.Text.Substring(0, orindex - 1) + "%' OR field1 LIKE '%" + txt.Text.Substring(innerORindex, andindex - innerORindex) + "%' AND field1 LIKE '%" + txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex) + "%'";
Response.Write(qry);
notindex = 0;
}
}
}
if (orindex < notindex)
{
if (orindex > -1 && notindex > -1)
{
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, orindex - 1);
string BBA = txt.Text.Substring(innerORindex, innerNOTindex - innerORindex - 3);
string bbc = txt.Text.Substring(innerNOTindex, txt.Text.Length - innerNOTindex);
//qry = "Select * from table where field Like '%" + aaA + "%'OR field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + aaA + "%'OR field LIKE '%" + BBA + "%' AND field NOT LIKE '%" + bbc + "%' OR field1 Like '%" + aaA + "%'OR field1 LIKE '%" + BBA + "%' AND field1 NOT LIKE '%" + bbc + "%' ";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
//--------NOT CONDITION------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
bool chkh1 = txt.Text.Contains("AND");
bool chkhh = txt.Text.Contains("OR");
if (notindex == 0)
{
}
if (chkh1 == false && chkhh==false)
{
if (notindex > -1)
{
innerNOTindex = notindex + 3;
string aa = txt.Text.Substring(innerNOTindex);
// qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + aa + "%'";
qry = "Select * from table where field Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field NOT LIKE '%" + aa + "%' OR field1 Like '%" + txt.Text.Substring(0, notindex - 1) + "%'AND field1 NOT LIKE '%" + aa + "%'";
Response.Write(qry);
}
}
if (chkhh == false)
{
if (notindex < andindex)
{
if (notindex != 0)
{
if (notindex > -1 && andindex > -1)
{
innerANDindex = andindex + 3;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, notindex - 1);
string BBA = txt.Text.Substring(innerNOTindex, innerANDindex - innerNOTindex - 3);
string bbc = txt.Text.Substring(innerANDindex, txt.Text.Length - innerANDindex);
//qry = "Select * from table where field Like '%" + aaA + "%'AND field NOT LIKE '%" + BBA + "%' AND field LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + aaA + "%'AND field NOT LIKE '%" + BBA + "%' AND field LIKE '%" + bbc + "%' OR field1 Like '%" + aaA + "%'AND field1 NOT LIKE '%" + BBA + "%' AND field1 LIKE '%" + bbc + "%'";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
}
}
if (chkh1 == false)
{
if (notindex < orindex)
{
if (orindex > -1 && notindex > -1)
{
innerORindex = orindex + 2;
innerNOTindex = notindex + 3;
string aaA = txt.Text.Substring(0, notindex - 1);
string BBA = txt.Text.Substring(innerNOTindex, orindex - innerNOTindex);
string bbc = txt.Text.Substring(innerORindex, txt.Text.Length - innerORindex);
//qry = "Select * from table where field Like '%" + aaA + "%' AND field NOT LIKE '%" + BBA + "%' OR field LIKE '%" + bbc + "%'";
qry = "Select * from table where field Like '%" + aaA + "%' AND field NOT LIKE '%" + BBA + "%' OR field LIKE '%" + bbc + "%' OR field1 Like '%" + aaA + "%' AND field1 NOT LIKE '%" + BBA + "%' OR field1 LIKE '%" + bbc + "%' ";
Response.Write(qry);
orindex = 0;
notindex = 0;
}
}
}
}
}
Subscribe to:
Comments (Atom)