public ExecuteFile ( string filePath, string basePath = null ) : bool | ||
filePath | string | The SQL file to execute |
basePath | string |
/// The base path to use to qualify relative path of any included files that are to be executed.
/// If not supplied this will default to the directory path containing |
return | bool |
public bool ExecuteFile(string filePath, string basePath = null)
{
if (string.IsNullOrEmpty(basePath))
{
basePath = Path.GetDirectoryName(filePath);
}
using (var stream = File.OpenRead(filePath))
{
return ExecuteStream(stream, basePath);
}
}
SqlCmd::ExecuteFile ( |
/// <summary> /// Executes a SQL file on the given connection /// </summary> /// <param name="conn">Connection to execute the file on</param> /// <param name="file">The SQL file being executed</param> public static void ExecuteFile( SqlConnection conn, string filePath) { var sqlCmd = new SqlCmd(conn); sqlCmd.ExecuteFile(filePath); }