多线程和SQL [英] multi threading and sql

查看:250
本文介绍了多线程和SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#程序,其中有30个线程同时运行.当我调用函数或存储过程从DB接收数据时,这些线程中的每个线程都通过单独的sql连接连接到相同的数据库,在6%的情况下(连接是打开的),我什么也没收到.存储过程正常工作,因为我已将SP的结果存储在DB的表中.这个问题开始是因为我向数据库添加了一个表,该表的每个记录都有8 kb的数据,并且每个线程的进程变长了,但是数据和错误的负载才是进程的开始.关于这个问题有任何建议吗(c# .net 2.5 sql server 2008)

I have a C# program that has 30 threads running simoltaneously. Each of these threads are connected to the same data base whith seperated sql Connections when I call functions or stored procedures to receive data from the DB I didn''t receive anything in 6% of cases (the connection is open) I should mention that the stored procedures is working correctly because I have stored the result of the SP in a table in DB. This problem starts since I Add a table to DB that each record of that has 8 kb Data and the process of each thread got longer however load of data and error is at the beginning of process.Is there any suggestion about this problem.(c# .net 2.5 sql server 2008)

推荐答案

如果我正确地理解了说明,那么如果执行过程花费很长时间,则可能是超时问题.您是否收到任何错误消息,并且在线程中具有正确的错误处理?

另外,如果您正在某些线程中修改数据,那么这也可能是并发问题,另一个线程会修改数据,但在另一个线程读取数据时尚未提交它.
If I understood the description correctly, this could be a timeout issue if the execution of a procedure takes a long time. Do you get any error messages and do you have proper error handling in the threads.

Also if you''re modifying the data in some of the threads it could also be a concurrency issue, another thread modifies the data but hasn''t committed it yet while another reads the data.


这篇关于多线程和SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆