简体   繁体   English

使用C#将.sql文件加载到DataSet或DataTable

[英]Load .sql file to a DataSet or DataTable with C#

Is it possible to load a .sql file into a DataSet or DataTable without executing it on a SQL Server database and then read the values from the database? 是否可以将.sql文件加载到DataSetDataTable而不在SQL Server数据库上执行该文件,然后再从数据库中读取值?

I know the way to load the .sql file into SQL Server and then read out the values, but is there a way to skip this because I don't have the option to create a SQL Server on the PC at the moment. 我知道将.sql文件加载到SQL Server中然后读出值的方法,但是有一种方法可以跳过此操作,因为目前我无法选择在PC上创建SQL Server。

The .sql file has a CREATE TABLE statement and a INSERT INTO query with some data .sql文件具有CREATE TABLE语句和带有一些数据的INSERT INTO查询

Greetz. 格尔茨。

In-Memory SQSQLite or SQL Server CE maybe? 内存中的SQSQLite还是SQL Server CE? Depends on whats in your SQL file, and if there are any SQL Server specific statements. 取决于SQL文件中的内容以及是否有任何SQL Server特定的语句。

In that case it pretty much boils down to 在那种情况下,它可以归结为

  1. In-memory database (would be my preferred option) 内存数据库(将是我的首选)
  2. Parsing the file directly using a custom adapter. 使用自定义适配器直接解析文件。 Maybe its a good idea for you to start an open source project. 也许对您来说开始一个开源项目是一个好主意。 And once you come across hiccups to ask for help ;-) 一旦遇到麻烦请寻求帮助;-)

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

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