<html><body><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000"><div>Hi all,<br></div><div><br></div><div>Another noob db question, is there anything I can do make this error more friendly?:<br></div><div><br></div><div>>In file 'ink_settings_unit1.pas' at line 65:<br>>INK_SQL.SQL.Text := 'INSERT INTO ink_settings(id, setting_type, basebalance_date, latest_data) ' +</div><div>?<br></div><div><br></div><div>I have this code structure for updating/inserting data:<br></div><div><br></div><div>try<br> result := false;<br> Try<br> InitializeDB();<br> //Not using StartTransaction for db is already active<br> SQLStr:='UPDATE ink_settings SET latest_data=0 WHERE setting_type=''%s''';<br> SQLStr:= Format(SQLStr,[INK_SETTING_TYPE]);<br> INK_SQL.SQL.Text := SQLStr;<br> INK_SQL.ExecSQL;<br><div><br></div> DateSTR:=FormatDateTime('MM-DD-YYYY hh:mm:ss',NewBaseDate);<br><div><br></div> NEW_INK_SETTINGID := GetTablePrimaryID('ink_settings') + 1;<br> //Insert new base date<br> INK_SQL.SQL.Text := 'INSERT INTO ink_settings(id, setting_type, basebalance_date, latest_data) ' +<br> ' VALUES (:NEWID,:SETTING_TYPE,:NEWDATE,:LATEST_DATA)';<br> INK_SQL.Params.ParamByName('NEWID').AsInteger := NEW_INK_SETTINGID;<br> INK_SQL.Params.ParamByName('SETTING_TYPE').AsString := INK_SETTING_TYPE;<br> INK_SQL.Params.ParamByName('NEWDATE').AsString := DateSTR;<br> INK_SQL.Params.ParamByName('LATEST_DATA').AsInteger := INK_LATEST_DATA;<br> INK_SQL.ExecSQL;<br><div><br></div> INK_TRANSACTION.Commit;<br><div><br></div> result := True;<br><div><br></div> except<br> on e: exception do // Catch my exception<br> begin<br> raise exception.Create('Error: ' + e.Message);<br> end;<br> end;<br> finally<br> FreeDB();<br> end; </div><div><br></div><div>Where InitializeDB() code:<br></div><div><br></div><div>procedure InitializeDB();<br> begin<br> INK_DB := TPQConnection.Create(nil);<br> INK_SQL := TSQLQuery.Create(nil);<br> INK_TRANSACTION := TSQLTransaction.Create(nil);<br> INK_DATASOURCE := TDatasource.Create(nil);<br> if not INK_DB.Connected then<br> begin<br> INK_DB.HostName := DATABASE_HOST;<br> INK_DB.DatabaseName := DATABASE_NAME;<br> INK_DB.UserName := DATABASE_USER;<br> INK_DB.Password := DATABASE_PASSWORD;<br> INK_DB.Connected := True;<br><div><br></div> INK_SQL.database := INK_DB;<br> INK_TRANSACTION.DataBase := INK_DB;<br> INK_TRANSACTION.Active := True;<br> INK_DATASOURCE.DataSet := INK_SQL;<br> INK_SQL.Transaction := INK_TRANSACTION;<br> end;<br> end;</div><div><br></div><div><br></div><div>Thank you for any ideas...<br></div><div><br></div><div>Regards,<br></div><div>Allan<br></div><div><br></div><div><br></div></div></body></html>