C# 执行SQL事务实例代码
[C#]
public void RunSqlTransaction(string myConnString)
{
SqlConnection myConnection = new SqlConnection(myConnString);
myConnection.Open();
SqlCommand myCommand = myConnection.CreateCommand();
SqlTransaction myTrans;
// Start a local transaction
myTrans = myConnection.BeginTransaction();
// Must assign both transaction object and connection
// to Command object for a pending local transaction
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;
try
{
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, ´Description´)";
myCommand.ExecuteNonQuery();
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, ´Description´)";
myCommand.ExecuteNonQuery();
myTrans.Commit();
Console.WriteLine("Both records are written to database.");
}
catch(Exception e)
{
try
{
myTrans.Rollback();
}
catch (SqlException ex)
{
if (myTrans.Connection != null)
{
Console.WriteLine("An exception of type " + ex.GetType() +
相关文档:
交叉表语句的实现:
用于:交叉表的列数是确定的
select name,sum(case subject when '数学' then source else 0 end) as '数学',
sum(case subject when '英语' then source else 0 end) as '英语',
sum(case subject when '语文' then source else 0 end) as '语文'
from test
group by name ......
SQL重复记录查询
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from
people
where peopleId in (select peopleId from people group by peopleId
having count
(peopleId) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(p ......
2009-11-18 12:51:46
限定处理记录的单位,rowcount=100表式每次处理100条数据。实际处理的记录数由rowcount和where子句决定。如果符合where的记录数大于rowcount,则有rowcount决定,如果小于rowcount,则由where决定。
create table tb(id int identity(1,1),num int)
insert into tb
values(1)
while @@ ......
引自http://www.05112.com/Article/200908/26674.html
网站SQL注入漏洞全接触(高级篇)
文章整理发布:黑客风云 内容关注度:
291 更新时间:2009-8-15 6:36:47
看完入门篇和进阶篇后,稍加练习,破解一般的网站是没问题了。但如果碰到表名列名猜不到,或程序作者过滤了一些特殊字符,怎么提高注入的成功率?怎 ......
使用整数数据的精确数字数据类型。
bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数据(所有数字)。
存储大小为 8 个字节。
int 从 -2^31 (-2,147,483,648) 到 2^31 - 1 (2,147,483,64 ......