这是我用来从MerchantID数据库获取LocationID的代码.我从Fill数据集部分得到一个例外.请帮帮我.错误是将数据类型varchar转换为bigint时出错.
public DataSet getLocationID(long MerchantID)
{
//long LOCID = null;
try
{
SqlParameter[] parameters = new SqlParameter[]
{
new SqlParameter("@merchantID",MerchantID)
};
string strCommandText = "Select LocationID from Merchant_Location where MerchantID ='@merchantID' order by LocationID ASC";
Debug.WriteLine(strCommandText);
DataSet pds = new DataSet();
SqlHelper.FillDataset(DbConnString, System.Data.CommandType.Text, strCommandText, pds, new string[] { "LocID" }, parameters);
return pds;
}
catch (Exception ex)
{
//LogError("Error Occurred When Retrieving LocationID: " + MerchantID.ToString(), ex);
return null;
}
}
Run Code Online (Sandbox Code Playgroud) 拥有由脚本[1]定义的表,我在SSMS的2个窗口中执行脚本
--1) first in first SSMS window
set transaction isolation level READ UNCOMMITTED;
begin transaction;
update aaa set Name ='bbb'
where id=1;
-- results in "(1 row(s) affected)"
--rollback
Run Code Online (Sandbox Code Playgroud)
之后1)
--2)after launching 1)
select * from aaa --deleted comments
where id<>1
--is blocked
Run Code Online (Sandbox Code Playgroud)
独立于1)窗口中的事务隔离级别,2)中的SELECT被阻止.
为什么?
UPDATE的隔离级别是否会对其他事务的语句产生任何影响?
最高隔离级别是2)中的默认READ COMMITTED.
没有范围锁被归因,SELECT应该遭受COMMITTED READS(NONREPEATABLE READs)和PHANTOM READS(可重复读取)问题[2]
如何让它受到影响?
如何在不阻塞SELECT的情况下进行UPDATE?
[1]
CREATE TABLE aaa
(
Id int IDENTITY(1,1) NOT NULL,
Name varchar(13) NOT NULL
)
insert into aaa(Name)
select '111' union all
select '222' union all …Run Code Online (Sandbox Code Playgroud) 我有一些C#的经验,并希望提高我对其最新改进的了解.我现在正在阅读和享受Bill Wagner的"Effective C#".但是,我会感谢更多的例子,尤其是lambda表达式等.
任何建议都非常感谢.优质的资源是优选的,如果它们是免费的则无关紧要.
我有一个特殊的情况。我的表经常被代码的不同部分和数千个客户端访问,因此我们在表上进行简单的更新和插入时使用了事务。问题是我们不断遇到死锁错误。有人知道我可以如何缓解这个问题吗?