gpt4 book ai didi

asp.net - 在SQL Server 2005中同时从多台计算机插入同一数据库中的记录时出现问题

转载 作者:行者123 更新时间:2023-12-02 12:13:44 24 4
gpt4 key购买 nike

我有一个用 ASP.NET 设计的 Web 门户,我们要求客户在其中输入数据。单击提交按钮后,我所做的就是读取数据并调用一个存储过程,将其插入到表中。同时从多台计算机插入数据时,SQL Server 2005 似乎存在问题。我们在实验室中使用三台计算机进行了测试,结果是我们仅在一台计算机上成功插入数据,而在其他两台计算机上我们在页面上出现错误。

我已经在存储过程中使用了事务,并且还尝试将隔离级别设置为 READ_UNCOMMITTED、SERIALIZABLE 和 SNAPSHOT。似乎没有什么能正常工作。我对过去一天的这件事感到沮丧。非常感谢任何帮助。

谢谢,马诺杰

最佳答案

我认为这是因为您正在使用事务...

根据 here :

BEGIN TRANSACTION starts a localtransaction for the connection issuingthe statement. Depending on thecurrent transaction isolation levelsettings, many resources acquired tosupport the Transact-SQL statementsissued by the connection are locked bythe transaction until it is completedwith either a COMMIT TRANSACTION orROLLBACK TRANSACTION statement.Transactions left outstanding for longperiods of time can prevent otherusers from accessing these lockedresources, and also can prevent logtruncation.

就您的情况而言,您同时使用 3 台计算机测试了您的应用程序。由于您正在使用事务,如果这些用户在您的数据库中同时使用相同的资源(您的 SP、表等...),则该特定资源将被锁定,其他用户将无法使用它除非第一个用户的事务已完成或提交。

这是我发现的一篇好文章: http://omaralzabir.com/linq_to_sql_solve_transaction_deadlock_and_query_timeout_problem_using_uncommitted_reads/

关于asp.net - 在SQL Server 2005中同时从多台计算机插入同一数据库中的记录时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4162160/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com