SQL Server 2008 Express 一行写入
我在使用 SQL Server Express 2008 时遇到了最奇怪的问题(至少对我来说很奇怪)。
问题如下:
在开发计算机上,我使用 SQL Server 2008 Enterprise....我从 WCF 服务获取一些数据,并且将数据写入数据库(尽可能简单)......但是我应该指出,写入是在单独的线程中完成的。但是,无论如何,在开发过程中没有问题......所有数据都在那里。
然后我在 Release 中设置所有内容(连接字符串 .\SQLEXPRESS,其他设置)并将其复制到安装了 SQL Server Express 的测试机器(因为我的应用程序是客户端应用程序,它应该与 Express 一起使用)...我运行程序...程序从服务中检索数据...当我查看数据库时...我大吃一惊...只写入了一行(从WCF 服务)。
我真的很感激任何帮助......我在这里陷入僵局。
I have the most bizarre problem (at least it is bizarre to me) with SQL Server Express 2008.
The problem is the following:
On the development machine I use SQL Server 2008 Enterprise....I get some data from a WCF service and write that data to the database (simple as it can be)....I should point out however that the writing, it is done in a separate thread. But, anyway no problems during development...all the data is there.
Then I set everything up(connection strings .\SQLEXPRESS, other settings) build in Release and copy that to a test machine that has SQL Server Express installed (because my application is a client application and it should work with Express)... I run the program.... the program retrieves the data from the service... and when I look at the database... I'm in for a big surprise... there's only one row written (the first row received from the WCF service).
I would really appreciate any help...I'm in a deadlock here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,有人会发现这很有趣...
经过彻底分析后,发生了这种情况:
我将正在将数据写入在不同线程中运行的数据库的代码移动到与 GUI 相同的线程...并且没有问题它工作正常...它将所有数据写入数据库。
我进一步查看,发现网上一篇文章说 SQL Express 只有一个调度程序(当然还有一个处理器等)...因此它不支持同时向数据库写入多个线程(任何人其他人对此了解更多吗?)...因此,解决方案可能是创建一个队列,然后在数据到达时将其发送到队列,并将数据一一写入数据库。
OK, someone will find this interesting...
After a thorough analysis this happened:
I moved the code that was writing the data to the db that was running in a different thread to the same thread as the GUI....and no problem it works fine...it writes all the data to the database.
I looked further on and came up on an article on the web saying that SQL Express has only one scheduler(and of course one processor etc.)...and therefore it doesn't support multiple threads writing to the database at once(anyone else knows more about this?)...therefore the solution for this is probably creating a queue and just send stuff to it as it arrives and write data one by one to the database.
您能够分析 sql 服务器上实际调用的内容吗?
打开 sql server profiler,指向 sql express 实例并确保拉取 RPC:Completed 和 Sql Statement Completed。您可以取消选中默认值的其余部分,这可能会告诉您它如何在服务器上以不同的方式调用它。
其他想法:
命令类型是否正确?
顶部怎么会滑进去?
Are you able to profile what is actually being called on the sql server?
Open up the sql server profiler, point the sql express instance and make sure you pull the RPC:Completed and Sql Statement Completed. You can uncheck the rest of the default, this might be able to tell you how its possibly calling it differently on the server.
Other thoughts:
Is the command type correct?
Is a top slipping in there some how?
仔细检查所有内容(尤其是连接字符串)。让您的应用程序输出一个日志文件,这可能有助于调试您的问题。
还要检查主数据库,以确保条目不会无意中写入开发数据库。
Double-check everything (especially connection strings). Have your app output a log file which might help debug your problem.
Check the main DB also to make sure the entries aren't inadvertently written to the development database.
你有没有机会设置(我知道这不太可能)
Have you by any chance set(I know this is unlikely)