In the process of MSDE operations. Execute some SQL scripts. Some are from
The SQL statement generated in SQL Server 2000 is a suffix script. There is no Enterprise Manager in MSDE,
All operations are completed in the program. Use the following functions to execute SQL scripts.
// Execute an SQL file. The file can only be ANSI encoded.
// If the file is unicode encoded, it will be garbled.
VaR
S: string;
Sqltext: string;
Sqlfile: textfile;
Begin
If opendialog1.execute then
Begin
Assignfile (sqlfile, opendialog1.filename );
Filemode: = 0;
Reset (sqlfile );
Try
Adoconnection1.begintrans;
While not EOF (sqlfile) Do
Begin
Readln (sqlfile, S );
Sqltext: = s;
While (not EOF (sqlfile) and
(Uppercase (TRIM (s) <> 'Go') Do
Begin
Readln (sqlfile, S );
If (uppercase (TRIM (s) <> 'Go') then
Sqltext: = sqltext + ''+ S;
End;
Adoquery1.close;
Adoquery1. SQL. Clear;
Adoquery1. SQL. Add (sqltext );
Adoquery1.execsql;
End;
Closefile (sqlfile );
Adoconnection1.committrans;
Application. MessageBox ('SQL corner finished! ',
'Hprompt ', mb_ OK + mb_iconinformation );
Except
Raise exception. Create ('SQL corner execution failed! ');
Adoconnection1.rollbacktrans;
End;
End;
End;
Adoconnection1, adoquery1, and opendialog1 are controls placed in the window. You can set it as a local variable to create and destroy it in this function.
20:03:52