@@ -87,17 +87,21 @@ function TSQLiteConfig.GetDefaultDir(aFileName: string): string;
8787function TSQLiteConfig.getValue (pKey: string): string;
8888begin
8989 Result := ' ' ;
90- with FDataSet do
91- begin
92- Close;
93- SQL.Clear;
94- SQL.Add(' SELECT CFG_Value' );
95- SQL.Add(' FROM Config' );
96- SQL.Add(' WHERE CFG_Key = :CFG_Key' );
97- ParamByName(' CFG_Key' ).Value := pKey;
98- Open;
99- Result := Fields.Fields[0 ].AsString;
100- Close;
90+ try
91+ with FDataSet do
92+ begin
93+ Close;
94+ SQL.Clear;
95+ SQL.Add(' SELECT CFG_Value' );
96+ SQL.Add(' FROM Config' );
97+ SQL.Add(' WHERE CFG_Key = :CFG_Key' );
98+ ParamByName(' CFG_Key' ).Value := pKey;
99+ Open;
100+ Result := Fields.Fields[0 ].AsString;
101+ Close;
102+ end ;
103+ except
104+ Result := ' ' ;
101105 end ;
102106end ;
103107
@@ -212,27 +216,27 @@ procedure TSQLiteConfig.SaveForm(aForm: TForm);
212216procedure TSQLiteConfig.UpdateConfig (aJSON: TJSONObject);
213217var
214218 JSONVal: TJSONValue;
215- i : integer;
219+ I : integer;
216220begin
217221 // exemplo entrada
218222 // {"key1":"value1", "key2":"value2", "key3":"value3", "key4":"value4", "key5":"value5"}
219223 // aJSON.Pairs[i].JSONString.tostring = "key1",
220224 // aJSON.Pairs[i].JSONValue.tostring = "value1";
221- for i := 0 to aJSON.Count - 1 do
225+ for I := 0 to aJSON.Count - 1 do
222226 with FDataSet do
223227 begin
224228 Close;
225229 SQL.Clear;
226230 SQL.Add(' SELECT CFG_Key, CFG_Value' );
227231 SQL.Add(' FROM Config' );
228232 SQL.Add(' WHERE CFG_Key = :CFG_Key' );
229- ParamByName(' CFG_Key' ).Value := aJSON.Pairs[i ].JsonString.ToString.Replace
233+ ParamByName(' CFG_Key' ).Value := aJSON.Pairs[I ].JsonString.ToString.Replace
230234 (' "' , ' ' , [rfReplaceAll]);
231235 Open;
232236 Edit;
233- Fields.Fields[0 ].Value := aJSON.Pairs[i ].JsonString.ToString.Replace(' "' ,
237+ Fields.Fields[0 ].Value := aJSON.Pairs[I ].JsonString.ToString.Replace(' "' ,
234238 ' ' , [rfReplaceAll]);
235- Fields.Fields[1 ].Value := aJSON.Pairs[i ].JsonValue.ToString.Replace(' "' ,
239+ Fields.Fields[1 ].Value := aJSON.Pairs[I ].JsonValue.ToString.Replace(' "' ,
236240 ' ' , [rfReplaceAll]);
237241 Post;
238242 if FDataSet.CachedUpdates then
@@ -277,7 +281,7 @@ function TSQLiteConfig.ValidaBanco: boolean;
277281
278282function TSQLiteConfig.Validate : boolean;
279283begin
280- Result := false ;
284+ Result := False ;
281285 try
282286 with FDataSet do
283287 begin
@@ -298,7 +302,7 @@ function TSQLiteConfig.Validate: boolean;
298302 end ;
299303 Result := true;
300304 except
301- Result := false ;
305+ Result := False ;
302306 end ;
303307end ;
304308
0 commit comments