asp.net µ÷Óô洢¹ý³Ì
1.»ñÈ¡Return·µ»ØÖµ
³ÌÐò´úÂë//´æ´¢¹ý³Ì
//Create PROCEDURE MYSQL
// @a int,
// @b int
//AS
// return @a + @b
//GO
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString());
conn.Open();
SqlCommand MyCommand = new SqlCommand("MYSQL", conn);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int));
MyCommand.Parameters["@a"].Value = 10;
MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int));
MyCommand.Parameters["@b"].Value = 20;
MyCommand.Parameters.Add(new SqlParameter("@return", SqlDbType.Int));
MyCommand.Parameters["@return"].Direction = ParameterDirection.ReturnValue;
MyCommand.ExecuteNonQuery();
Response.Write(MyCommand.Parameters["@return"].Value.ToString());
2.»ñÈ¡OutputÊä³ö²ÎÊýÖµ
³ÌÐò´úÂë//´æ´¢¹ý³Ì
//Create PROCEDURE MYSQL
// @a int,
// @b int,
// @c int output
//AS
// Set @c = @a + @b
//GO
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString());
conn.Open();
SqlCommand MyCommand = new SqlCommand("MYSQL", conn);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int));
MyCommand.Parameters["@a"].Value = 20;
MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int));
MyCommand.Parameters["@b"].Value = 20;
MyCommand.Parameters.Add(new SqlParameter("@c", SqlDbType.Int));
MyCommand.Parameters["@c"].Direction = ParameterDirection.Output;
MyCommand.ExecuteNonQuery();
Response.Write(MyCommand.Parameters["@c"].Value.ToString());
Ïà¹ØÎĵµ£º
Asp.net ÖÐÔÚ¿Í»§¶Ë´¥·¢·þÎñÆ÷¶Ëʼþ·ÖΪÁ½ÖÖÇé¿ö£º
Ò». WebControlsÖеÄButton ºÍHtmlControlsÖеÄTypeΪsubmitµÄHtmlInputButton
ÕâÁ½ÖÖ°´Å¥×îÖÕµ½¿Í»§¶ËµÄ±íÏÖÐÎʽΪ£º<input type="submit" value="Submit">£¬ÕâÊÇForm±íµ¥µÄÌá½»°´Å¥£¬µã»÷ÒÔºó»á×÷Ϊ²ÎÊý·¢Ë͵½·þÎñ¶Ë£¬²ÎÊýÊÇÕâÑùµÄ£º
¿Ø¼ ......
Ê×ÏÈÒªÌí¼Ó
using System.Data;
using System.Data.SqlClient;
½ÓÏÂÀ´£º
SqlConnection conn = new SqlConnection("server=QLPC\\SQL2005;uid=sa;pwd=£¨ÄãµÄÃÜÂ룩;database=£¨ÄãµÄÊý¾Ý±í£©"); &n ......
ASP.NETÎļþÏÂÔغ¯ÊýʹÓÃÊÇʲôÇé¿öÄØ£¿ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success) Response.Write("ÏÂÔØÎļþ³ö´í£¡"); Page.Response.End();
ASP.NETÎļþÏÂÔغ¯Êý´úÂëΪ:
......
——Áé»îÔËÓà Form ±íµ¥ÈÏÖ¤ÖÐµÄ deny Óë allow ¼°±£»¤ .htm µÈÎļþ
×÷Õߣºº®Óð·ã(cityhunter172)
µÚ¶þ²¿·Ö Form ÈÏÖ¤µÄʵսÔËÓÃ
»°ËµÉϻأ¬¼òµ¥µØ˵ÁËһϠForm ±íµ¥ÈÏÖ¤µÄÓ÷¨¡£»òÐí´ó¼Ò¾õµÃÌ«¼òµ¥£¬¶ÔÄÇЩ´óÄÚ¸ßÊÖÀ´ËµÓ¦¸ÃÊÇ“È÷È÷Ë®À²”“С Kiss À²£¨Ð¡Òâ˼£©”¡£½ñÌìÔÛÃÇÀ´µã ......
1.Server.MapPath("/") //Ó¦ÓóÌÐò¸ùĿ¼ËùÔÚµÄλÖà Èç C:\Inetpub\wwwroot\
2.Server.MapPath("./") //±íʾËùÔÚÒ³ÃæµÄµ±Ç°Ä¿Â¼
//×¢£ºµÈ¼ÛÓÚServer.MapPath("") ·µ»Ø Server.MapPath("")ËùÔÚÒ³ÃæµÄ//ÎïÀíÎļþ·¾¶
3.Server.MapPath("../")//±íʾÉÏÒ»¼¶Ä¿Â¼
4.Server.MapPath("~/../");//±íʾ±¾ÎļþËùÔÚÎļþ¼ ......