Executing a SQL script stored as a resource

Viewed 25896

I would like to store lengthy .sql scripts in my solution and execute them programmatically. I've already figured out how to execute a string containing my sql script but I haven't figured out how to read the string from a file that would be stored in the solution (under a /Scripts subfolder for example).

4 Answers

Add file to Resources, and set file to Resource, in code write:

String SQLCommand = NAMESPACE.Properties.Resources.ScriptDB.ToString()
Related