简体   繁体   English

如果需要在INSERT调用之间进行SELECT调用,如何在C#中将准备好的语句与SQLite一起使用?

[英]How do I use prepared statements with SQLite in C# if I need to do a SELECT call between INSERT calls?

I am working on a project that has to enter about 80,000 row entries into a database per run. 我正在做一个项目,每次运行必须向数据库中输入大约80,000行条目。 I've been able to speed it up a lot thanks to prepared statements. 由于准备了语句,我已经能够大大加快速度。 However, I am running into a problem where one last area where I need to make a lot of row entries relies on data from SELECT calls made between INSERT statements due to the involvement of foreign keys. 但是,我遇到了一个问题,由于涉及外键,我需要做很多行条目的最后一个区域依赖于INSERT语句之间进行的SELECT调用中的数据。 In all of the examples I have seen of prepared statements, it was all for ExecuteNonQuery() command calls. 在我看到的所有有关预准备语句的示例中,所有这些都是用于ExecuteNonQuery()命令调用的。

Am I allowed to use prepared statements with a SELECT query call in the same transaction as INSERT calls as long as nothing besides the values are changed in the SQLiteCommand.CommandText values or is there a different way I need to approach this? 我是否可以在与INSERT调用相同的事务中使用带有SELECT查询调用的准备好的语句,只要除SQLiteCommand.CommandText值中的值以外没有其他更改,否则是否有其他方法可以解决?

您可以使用准备好的语句执行SELECT命令,但必须再创建一个SQLiteCommand对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM