ASP.NETºÍSQL SERVERÖÐʹÓÃÊÂÎñʾÀý
1£¬SqlServer´æ´¢¹ý³ÌµÄÊÂÎñ´¦Àí
Ò»ÖֱȽÏͨÓõijö´í´¦ÀíµÄģʽ´ó¸ÅÈçÏ£º
Create procdure prInsertProducts
(
@intProductId int,
@chvProductName varchar(30),
@intProductCount int
)
AS
Declare @intErrorCode int
Select @intErrorCode=@@Error
Begin transaction
if @intErrorCode=0
begin
-insert products
insert products(ProductID,ProductName,ProductCount)
s(@intProductId,@chvProductName,@intProductCount)
Select @intErrorCode=@@Error --ÿִÐÐÍêÒ»Ìõt-sqlÓï¾äÂíÉϽøÐмì²â£¬²¢°Ñ´íÎóºÅ±£´æµ½¾Ö²¿±äÁ¿ÖÐ
end
if @intErrorCode=0
begin
-update products
update products set ProductName='MicroComputer' where ProductID=5
Select @intErrorCode=@@Error
end
if @intErrorCode=0
commit transaction
else
rollback transaction
Return @intErrorCode --×îºÃ·µ»Ø´íÎó´úºÅ¸øµ÷ÓõĴ洢¹ý³Ì»òÓ¦ÓóÌÐò
2£¬.NetÖÐʹÓÃÊÂÎñ´¦Àí
SqlConnection myConnection = new SqlConnection("Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;");
myConnection.Open();
SqlTransaction myTrans = myConnection***ginTransaction(); //ʹÓÃNewÐÂÉú³ÉÒ»¸öÊÂÎñ
SqlCommand myCommand = new SqlCommand();
myCommand.Transaction = myTrans;
try
{
myCommand.CommandText = "Update Address set location='23 rain street' where userid='0001'";
myCommand.ExecuteNonQuery();
myTrans.Commit();
Console.WriteLine("Record is udated.");
}
catch(Exception e)
{
myTrans.Rollback();
Console.WriteLine(e.ToString());
Console.WriteLine("Sorry, Record can not be updated.");
}
finally
{
myConnection.Close();
}
Ïà¹ØÎĵµ£º
ÌõÐÎÂëÊÇÆù½ñΪֹ×á¢ÊµÓõÄÒ»ÖÖ×Ô¶¯Ê¶±ð¼¼Êõ¡£ÌõÐÎÂë¼¼Êõ¾ßÓÐÒÔϼ¸¸ö·½ÃæµÄÓŵã
¡¡¡¡A£®ÊäÈëËٶȿ죺Óë¼üÅÌÊäÈëÏà±È£¬ÌõÐÎÂëÊäÈëµÄËÙ¶ÈÊǼüÅÌÊäÈëµÄ5±¶£¬²¢ÇÒÄÜʵÏÖ“¼´Ê±Êý¾ÝÊäÈ딡£
¡¡¡¡B£®¿É¿¿ÐԸߣº¼üÅÌÊäÈëÊý¾Ý³ö´íÂÊΪÈý°Ù·ÖÖ®Ò»£¬ÀûÓùâѧ×Ö·ûʶ±ð¼¼Êõ³ö´íÂÊΪÍò·ÖÖ®Ò»£¬¶ø²ÉÓÃÌõÐÎÂë¼¼ÊõÎóÂëÂʵ ......
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
±¾½ÚÖ÷Òª½éÉÜʹÓÃCLR´´½¨±êÁ¿º¯Êý£¬±íÖµº¯ÊýºÍ¾ÛºÏº¯Êý¡£
Ëùν±êÁ¿º¯ÊýÖ¸µÄ¾ÍÊǴ˺¯ÊýÖ»·µ»ØÒ»¸öÖµ¡£±íÖµº¯Êý·µ»ØÖµÊÇÒ»¸ö±í¡£¾ÛºÏº¯ÊýÊÇÔÚselectÓï¾äÖÐʹÓõģ¬ÓÃÀ´¾ÛºÏÒ»¸ö½á¹û¼¯£¬ÀàËÆÓÚSum()»òÊÇCount()µÈÄÚÖõĺ¯Êý£¬¶øÇÒÕæÕýµÄ×Ô¶¨Òå¾ÛºÏº¯ÊýÄ¿Ç°Ö»ÄÜÓÃCLRÀ´ÊµÏÖ¡£
ÏÂÃæµÄÀý×ÓʹÓÃÁËSQLServer×Ô´øµÄpubsÊý¾Ý¿â¡£
1 ......
SQL×Ö·û´®´¦Àíº¯Êý´óÈ«(ת)2008-04-01 17:21SQL×Ö·û´®´¦Àíº¯Êý´óÈ«(ת)select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'ÔÆ',×Ö¶Î1£©=1; ×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´ ......
ÔÌûµØÖ·:http://blog.cnria.com/post/aspnet-form-e5b58ce5a597-e68f90e4baa4e9a1b5e99da2e79a84e8a7a3e586b3e696b9e6b395-from-e5b58ce5a597-aspnet-e8a1a8e58d95.aspx
Õâ¸öÎÊÌâµÄÔÒòÆäʵ²¢²»ÊÇasp.net ÔËÐлúÖƵÄÔÒò£¬¶øÊÇÒòΪÔÚhtmlÖб¾Éí¾Í²»ÔÊÐíform±êǩǶÌ×ʹÓã¬ÎÒÊÔ¹ýdocument.getelementbyid("search&q ......