在C#中运行数据库脚本 [英] Running Database scripts in C#
问题描述
如何在c#中运行数据库脚本(MySql db scripts)。
谢谢,
sirni。
使用脚本作为输入,分叉子进程并执行 mysql
命令行客户端。
尝试将脚本读取为一个文件并在其中逐个执行SQL命令是很有诱惑力的,但是在SQL脚本中有许多语句无法以此方式执行。
所以你必须重复mysql客户端的代码,以便运行SQL脚本。你自己喜欢和使用已经为此目的设计的程序。
How to run database scripts(MySql db scripts) in c#.
Thanks, sirni.
Fork a child process and execute the mysql
command-line client, using the script as input.
It's tempting to try to read the script as a file and execute the SQL commands within it one by one, but there are numerous statements in an SQL script that can't be executed that way.
So you'd have to duplicate the code of the mysql client anyway in order to run an SQL script. Do yourself a favor and use the program that is already designed for that purpose.
这篇关于在C#中运行数据库脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!