What are ini read errors? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061224190355128.html
Filename: = extractfilepath (paramstr (0) + 'set. ini ';
Sid: = ini. readstring ('setconfig', 'serveruser', 'sa ');
Sname: = ini. readstring ('setconfig', 'servername', 'yyjys ');
Sdname: = ini. readstring ('setconfig', 'serverdbname', 'sims ');
INI. Free;
A memory error dialog box is displayed?
INI: = treginifile. Create; // have you done it?
Before you reply, I have found the error pull.
Try
Adotable1.active: = true;
Except
Begin
MessageBox (handle, 'Contact the administrator if you have any questions about database connection! ', 'Error', mb_ OK or mb_iconerror );
Application. Terminate;
End;
End;
When the connection fails
ThisCodeWhy not execute application. Terminate ???
GZ
VaR
Tempini: Tinifile;
Begin
Tempini: = Tinifile. Create (extractfilepath (paramstr (0) + 'sys. ini ');
Sqlservername: = tempini. readstring ('system', 'server ','');
Sqldbname: = tempini. readstring ('system', 'dbname ','');
Password: = tempini. readstring ('system', 'Password ','');
Tempini. Free;
Connstring: = 'provider = sqloledb.1; Password = '+ Password
+ '; Persist Security info = true; user id = sa; initial catalog ='
+ Sqldbname + '; Data Source =' + sqlservername;
Try
Sysdm. dbconnect. Connected: = false;
Sysdm. dbconnect. connectionstring: = connstring;
Sysdm. dbconnect. Connected: = true;
Except
On E: eoleexception do
Begin
If E. errorcode =-2147217843 then
Begin
Msshow ('the Database Password is incorrect! ');
End
Else if E. errorcode =-2147467259 then
Begin
Showmessage ('database server name or database name is incorrect! ');
Application. Terminate;
End;
End;
End;