TadoQuery.sql.LoadFromfile application

zhaozj2021-02-16  58

Always use the adoQuery.sql.add ('') method to perform SQL, but this can only be executed with a SQL statement until one day, I want to use AdoQuery to perform a lot of clearing the statement of the database, knowing to use LoadFromFile The method is extremely convenient. The routines are as follows:

Procedure tfrmmain.btnexecclick (sender: TOBJECT); var? cleandbqry: tadoquery; appp_: = extractfilepath: = extractfilepath (application.exename);

? ClearDbQry: = TAdoQuery.create (application); ????? CleardbQry.ConnectionString: = 'Provider = SQLOLEDB.1; Persist Security Info = False; User ID = sa; Password = UNISTOLLLINK; Initial Catalog = db; Data Source =. '; ????? Try ??????? ClearDbqry.close; ??????? ClearDbqry.sql.LoadFromFile (AppPath ClearDbdata.sql'); ??????? ClearDbqry .Execsql; ??????? ShowMessage ('clear success!'); ??????? Application.Terminate; ????? EXCEPT ??????? on E: Exception do showMessage E.MESSAGE); ????? end; ????? ClearDbqry.free;

END;

Remaining problem:

????? The SQL statement that uses LoadFromFile can be insert, delete, crete table, alter table, Drop Table, etc., but can no longer place multiple such statements when executing CREATE VIEW and CREATE Procedure is still another file. And these statements must be the first sentence, this is a defect!

转载请注明原文地址:https://www.9cbs.com/read-17553.html

New Post(0)