asp.net´Ósql server2005ÖвéѯÊý¾Ý
Ê×ÏÈÒªÌí¼Ó
using System.Data;
using System.Data.SqlClient;
½ÓÏÂÀ´£º
SqlConnection conn = new SqlConnection("server=QLPC\\SQL2005;uid=sa;pwd=£¨ÄãµÄÃÜÂ룩;database=£¨ÄãµÄÊý¾Ý±í£©"); //ÓÃÓÚÁ¬½ÓÊý¾Ý¿â
conn.Open(); //´ò¿ªÊý¾Ý¿â
SqlCommand cmd = new SqlCommand("select * from [user]", conn); //Ï൱ÓÚÖ´ÐÐÊý¾ÝÓï¾ä°É
SqlDataReader read = cmd.ExecuteReader(); //´´½¨Ò»¸öSqlDataReaderµÄreadÏó
while (read.Read()) //µ±¶ÁÈ¡µÄÊý¾Ý´æÔÚʱÔòд³öÀ´
{
Response.Write(read[0]);
}
conn.close(); //¹Ø±ÕÊý¾Ý¿âµÄÁ´½Ó
Ïà¹ØÎĵµ£º
ͨÅä·û_
"_"ºÅ±íʾÈÎÒâµ¥¸ö×Ö·û,¸Ã·ûºÅÖ»ÄÜÆ¥ÅäÒ»¸ö×Ö·û."_"¿ÉÒÔ·ÅÔÚ²éѯÌõ¼þµÄÈÎÒâλÖÃ,ÇÒÖ»ÄÜ´ú±íÒ»¸ö×Ö·û.Ò»¸öºº×ÖֻʹÓÃÒ»¸ö"_"±íʾ.
Àý×Ó£º
if PATINDEX('%[ß¹-×ö]%','ÐèÒªÅжϵÄ×Ö·û')>0 -- ÅжÏÊÇ·ñÓÐ×Ö·û
print 'Óкº×Ö'
else
print 'ÎÞºº×Ö'
ͨÅä·û%
"%"·ûºÅÊÇ×Ö·ûÆ¥Åä·û,ÄÜÆ¥Åä0¸ö»ò¸ü¶à×Ö·ûµÄÈÎÒⳤ¶ ......
Ëæ ×ÅÍøÕ¾·ÃÎÊÁ¿µÄ¼Ó´ó£¬Ã¿´Î´ÓÊý¾Ý¿â¶ÁÈ¡¶¼ÊÇÒÔЧÂÊ×÷Ϊ´ú¼ÛµÄ£¬ºÜ¶àÓÃACCESS×÷Êý¾Ý¿âµÄ¸ü»áÉîÓÐÌå»á£¬¾²Ì¬Ò³¼ÓÔÚËÑË÷ʱ£¬Ò²»á±»ÓÅÏÈ¿¼ÂÇ¡£»¥ÁªÍøÉÏÁ÷ ÐеÄ×ö·¨Êǽ«Êý¾ÝÔ´´úÂëдÈëÊý¾Ý¿âÔÙ´ÓÊý¾Ý¿â¶ÁÈ¡Éú³É¾²Ì¬Ã棬ÕâÑùÎÞÐμä¾Í¼Ó´óÁËÊý¾Ý¿â¡£½«ÏÖÓеÄASPÒ³Ö±½ÓÉú³É¾²Ì¬Ò³£¬½«»á½ÚÊ¡ºÜ¶à¡£
ÏÂÃæµÄÀý×ÓÊǽ«¡¢index.asp?i ......
ASP.NETÈý²ã½á¹¹ËµÃ÷
ÍêÉƵÄÈý²ã½á¹¹µÄÒªÇóÊÇ:Ð޸ıíÏÖ²ã¶ø²»ÓÃÐÞ¸ÄÂß¼²ã,ÐÞ¸ÄÂß¼²ã¶ø²»ÓÃÐÞ¸ÄÊý¾Ý²ã¡£·ñÔòÄãµÄÓ¦ÓÃÊDz»ÊǶà²ã½á¹¹,»òÕß˵ÊDzã½á¹¹µÄ»®·ÖºÍ×éÖ¯ÉÏÊDz»ÊÇÓÐÎÊÌâ¾ÍºÜÄÑ˵.²»Í¬µÄÓ¦ÓÃÓв»Í¬µÄÀí½â£¬ÕâÖ»ÊÇÒ»¸ö¸ÅÄîµÄÎÊÌ⣮
Àí½âASP.NETÈý²ã½á¹¹——ΪʲôҪ·ÖÈý²ã£¿
ÎÒÃÇÓÃÈý²ã½á¹¹Ö÷ÒªÊÇÊ¹Ï ......
1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º
´«ËͲÎÊý£º
response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</script>")
½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1.Attribut ......