2, deny the application in the data module code. MessageBox and showmessage?
Procedure TDm1. DataModuleCreate (Sender: TObject);
Var
Condbstr: string;
Path, datapath: string;
S, s1: string;
F: TextFile;//TextFile and Text is the same as
FileName: the string;
The begin
FileName:=ExtractFilePath (Paramstr (0)) + '\ data \ test TXT';//get the path of the TXT file
If fileExists (FileName) then//to determine whether a file exists
The begin
AssignFile (F, FileName);
Reset (F);//open read-only
Readln (F, s);//read IP first line
S1:=s;
Datapath:='\ \' + s1 + '\ kao $\';//IP sharing path
Path:=datapath + 'sjgl1. MDB';//file
Con1. Close;
Con1. Connected:=False;//close the validation
Try
Condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source=path; Persist Security Info=False ';
Con1. The ConnectionString:=condbstr;
Con1. Open;
Con1. LoginPrompt:=False;
Con1. Connected:=true;
Except,
Con1. Close;
Con1. Free;
//showmessage (' can't connect to the database! ');
//application. MessageBox (' can't connect to the database! ', 'prompt', 64);
//application. The Terminate;
end;
End
The else
//Application. ShowException (' do not have this file ');
end;
CodePudding user response:
Condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source=path; Persist Security Info=False ';It has a problem, change
Condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source='+ path +'; Persist Security Info=False ';
CodePudding user response:
Condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source= path ; Persist Security Info=False ';CodePudding user response:
Condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source='+ path +'; Persist Security Info=False ';CodePudding user response:
Thank you, is really condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source=path; Persist Security Info=False '; This error, instead condbstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source='+ path +'; Persist Security Info=False '; Connection, why use the application on the data module. The MessageBox, showmessage and application ShowException and ShowException denyCodePudding user response:
Condbstr:=format ('. The Provider=Microsoft Jet. The OLEDB. 4.0; The Data Source=% s. Persist Security Info=False ', (path));
CodePudding user response:
Path:=datapath + 'sjgl1. MDB';//file
Con1. Connected:=False;//close the validation
Try
Condbstr:=format ('. The Provider=Microsoft Jet. The OLEDB. 4.0; The Data Source=% s. Persist Security Info=False ', (path));
Con1. The ConnectionString:=condbstr;
Con1. LoginPrompt:=False;
Con1. Connected:=true;
Except,
Con1. Close;
end;
CodePudding user response:
Application. MessageBox showmessage and application ShowException these cannot be used, such as IP or file name error, is no place to prompt, finally complains "missing Connection or the ConnectionString"