What are ini read errors?

Source: Internet
Author: User
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.