com.rusanu.DBUtil.SqlCmd.ExecuteFile C# (CSharp) Method

ExecuteFile() public method

Executes a SQL file, from the file path
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);
			}
		}

Same methods

SqlCmd::ExecuteFile ( SqlConnection conn, string filePath ) : void

Usage Example

コード例 #1
0
ファイル: SqlCmd.cs プロジェクト: yasser10/Henalux
        /// <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);
        }
All Usage Examples Of com.rusanu.DBUtil.SqlCmd::ExecuteFile