Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

asp.net ¶à×Ö¶ÎÄ£ºý²éѯ´úÂë

¾­³£Óõ½¶à×ֶεÄÄ£ºý²éѯ£¬ÉÏÃæµÄº¯Êý¿ÉÒÔʵÏÖ£¬ÀýÈçstrKeyWordsֵΪ“½Å±¾Ö®¼Ò”ʱ
string strField = "id|className|classAdd";
string strKeyWords = this.tbxKeyWords.Text.Trim();
string strSql = dbexe.searchText("select * from class", strField, strKeyWords);
¾­³£Óõ½¶à×ֶεÄÄ£ºý²éѯ£¬ÉÏÃæµÄº¯Êý¿ÉÒÔʵÏÖ£¬ÀýÈçstrKeyWordsֵΪ“½Å±¾Ö®¼Ò”ʱ£¬¿ÉÒÔÊä³ö£º
select * from class where id like '%½Å±¾Ö®¼Ò%' or className like '%½Å±¾Ö®¼Ò%' or classAdd like '%½Å±¾Ö®¼Ò%'
º¯Êý£º
/// <summary>
/// ¸ù¾Ý¹Ø¼ü×ÖʵÏÖ¶à×Ö¶ÎÄ£ºý²éѯ
/// </summary>
/// <param name="sqlStr">select * from talbe sqlÓï¾ä</param>
/// <param name="sqlText">ÅжÏÓï¾äÌõ¼þ£¬ÊÇÒ»¸öÓÃ|¸ô¿ªµÄ×Ö·û´®</param>
/// <param name="keywords">¹Ø¼ü×Ö</param>
public static string searchText(string strSql, string strField, string keywords)
{
StringBuilder sb = new StringBuilder(strSql);
if (strField != string.Empty)
{
sb.Append(" where ");
string[] arrKey = strField.Split('|');
for (int i = 0; i < arrKey.Length; i++)
{
sb.Append(arrKey[i] + " like '%" + keywords + "%' or ");
}
string str = sb.ToString();
//È¥³ý×îºóÒ»¸ö"or"
if (str.IndexOf("or") >= 0)
{
return str.Remove(str.LastIndexOf("or"));
}
return str;
}
return strSql;
}
Ïêϸ³ö´¦²Î¿¼£ºhttp://www.jb51.net/article/15251.htm


Ïà¹ØÎĵµ£º

Parameter Queries in ASP.NET with MS Access

Parameter Queries in ASP.NET with MS Access
A selection of code samples for executing queries against MS Access using parameters.
Making use of the ASP.NET 2.0 datasource controls is fine, but it is important to understand how to manually create data access code. Best practice dictates that, at t ......

asp.netÒ³Ãæ¼ä´«ÖµµÄ9ÖÖ·½Ê½

1. Get(¼´Ê¹ÓÃQueryStringÏÔʽ´«µÝ)
     ·½Ê½£ºÔÚurlºóÃæ¸ú²ÎÊý¡£
     ÌØµã£º¼òµ¥¡¢·½±ã¡£
     ȱµã£º×Ö·û´®³¤¶È×Ϊ255¸ö×Ö·û£»Êý¾Ýй©ÔÚurlÖС£
     ÊÊÓÃÊý¾Ý£º¼òµ¥¡¢ÉÙÁ¿¡¢¹Ø¼üµÄÊý¾Ý¡£
     ÊÊÓ÷¶Î ......

Asp.net ʹÓÃ×ÊÔ´ÎļþʵÏÖË«ÓïÑÔ

¹«Ë¾½»¸øÎÒ¸öÏîÄ¿£¬ÒѾ­Íê³ÉÁËÒ»²¿·Ö£¬ÐèÒª×öÖÐÓ¢ÎÄË«ÓïÑÔ£¬ÒÔǰÌý±ðÈË˵³ÌÐò¶àÓïÑÔʲôµÄ£¬¶¼²»ÖªµÀ´ÓÄÄÏÂÊֵá£ÏîÄ¿¼Ü¹¹ÒѾ­´îºÃÁË£¬´ó¸Å¿´ÁËһϣ¬ÖªµÀÊÇʹÓÃ×ÊÔ´ÎļþÀ´ÊµÏֵ쬲»ËµÁË£¬¸Ï½ô×Ô¼ºÊÔÊÔ°É¡£ÊÔÁ˲Żá¼Çס£¬²ÅÊÇ×Ô¼ºµÄO(∩_∩)O~
 
1. н¨Asp.net WebÓ¦ÓóÌÐòChangeLanuage£¬Ð½¨aspxÒ³ÃæDefau ......

asp.net¡°·þÎñÆ÷Ó¦ÓóÌÐò²»¿ÉÓá± ½â¾ö·½·¨

ÒýÆðÕâ¸öµÄÔ­Òò´ó¸ÅÊÇÏÖ°²×°ÁË.Net Frameworkºó×°µÄIISµ¼ÖÂ.NetûÓÐÔÚIISÀï×¢²á¡£
ÔÚÍøÉÏÕÒÁ˺ܾö¼ÊÇ˵´Ó.netÃüÁîÐй¤¾ßÀïÔËÐÐaspnet_regIIS /i¾Í¿ÉÒÔÁË(»òÕßÔÚÀàËÆÏÂÃæµÄĿ¼£ºC:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i)£¬µ«ÊÇ×Ô¼ºÊÔÁ˺ܶà´Î¶¼²»ÐУ¬ºóÀ´·¢ÏÖ»¹ÊÇÒªÏÈÐ¶ÔØÔÙ°²×°£¬ÖØÐ´´½¨Îª ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ